2014-01-17 25 views
1

上的客户端应用程序谷歌云端点插入我跟谷歌的教程创建Android客户端发布简单的笔记来使用云终端的应用程序引擎的后端为在这里看到:从不灵本地服务器

https://developers.google.com/eclipse/docs/endpoints-create-fromandroid

我运行本地服务器,然后运行Android客户端应用程序,似乎都运行良好。没有错误报告。但是当我使用curl或API浏览器列出备注时,它将返回一个空集。

我一定要禁用我的病毒扫描程序并关闭我的防火墙。没有运气。我在手机上运行Android客户端(连接到我的无线网络),如果这有所作为。我永远无法让模拟器工作,它永远挂在引导屏幕上,所以我总是使用我的手机。

public class EndpointsTask extends AsyncTask<Context, Integer, Long> { 
    protected Long doInBackground(Context... contexts) { 

     Noteendpoint.Builder endpointBuilder = new Noteendpoint.Builder(
      AndroidHttp.newCompatibleTransport(), 
      new JacksonFactory(), 
      new HttpRequestInitializer() { 
      public void initialize(HttpRequest httpRequest) { } 
      }); 
    Noteendpoint endpoint = CloudEndpointUtils.updateBuilder(
    endpointBuilder).build(); 
    try { 
     Note note = new Note().setDescription("Note Description"); 
     String noteID = new Date().toString(); 
     note.setId(noteID); 

     note.setEmailAddress("E-Mail Address"); 
     Log.e("Debug", "Inserting note..."); 
     Note result = endpoint.insertNote(note).execute(); 
     Log.e("Debug", "Done inserting note!"); 
    } catch (IOException e) { 
    e.printStackTrace(); 
    } 
     return (long) 0; 
    } 
} 

有趣的是,:按谷歌的指示

插入代码被执行为的AsyncTask“完成插入笔记!”从不打印。我将进一步的调试放入insertNote函数本身,并使它成为return语句的一切。不确定它不可能返回吗?

关于如何解决这个问题的任何建议?谢谢。

回答

1

您是否在本地服务器上禁用了https?我认为这个协议在终端的开发模式下不起作用。

+0

我该怎么做? – user1464652

1

这听起来像是永远不会连接。我有点惊讶,你没有看到堆栈跟踪。是否有可能过滤来自LogCat的堆栈跟踪而没有看到它?

有两件事需要设置才能通过wifi连接到本地服务器(假设防火墙被禁用)。

  1. 使用由Eclipse生成的示例代码。在DeviceInfoEndpoint类中,您需要为注释@Api定义一个属性,您需要将<服务器IP >设置为服务器IP。 Eclipse的端口设置为8888。

    @Api(root = "http://<server ip>:8888/_ah/api", name = "deviceinfoendpoint", namespace = @ApiNamespace(ownerDomain = "gcetest.com", ownerName = "gcetest.com", packagePath = "")) 
    public class DeviceInfoEndpoint { 
    
  2. ,如文档中(-a对于--address选项的快捷方式)说下面你需要将地址选项设置为0.0.0.0

-a 0.0。 0.0

参见文档为devserver https://developers.google.com/appengine/docs/java/tools/devserver?csw=1

--address = ... 用于服务器的主机地址。您可能需要将其设置为能够从网络上的另一台计算机访问>开发服务器。地址0.0.0.0允许>本地主机访问和主机名访问。默认是localhost。

这可以在Eclipse中通过

  • 右键单击该项目并选择属性
  • 选择“运行/调试设置”
  • 选择应用程序引擎项目来完成在
  • 单击“编辑...”按钮
  • 选择“参数”选项卡
  • 在“Progr我的论点:”文本框中添加 “-a 0.0.0.0” 设置

的--port 8888之后应该是这个样子

--port = 8888 -a 0.0.0.0

  • 启动服务器
  • 重新生成客户端应用程序
  • 端点重新部署客户端应用程序

我认为应该解决你的问题。