注册Endpoints Server FAILED(App Engine连接Android项目)

时间:2014-01-14 14:41:46

标签: java android google-app-engine google-cloud-endpoints

我是Android编程和Google App Engine的新手。我按照以下文档运行了一个注册我的设备的示例应用程序:https://developers.google.com/eclipse/docs/endpoints-androidconnected-gae

当我运行应用程序(在设备上)时,我看到以下内容:

1)注册Google Cloud Messaging ...已成功!

2)注册Endpoints Server ...失败!

无法在云端点服务器上注册您的设备。您的云端点服务器未部署到应用引擎,或者您需要通过将LOCAL_ANDROID_RUN设置为“真实”来更改您的设置以针对本地实例运行。在CloudEndpointUtils.java中

我还检查了LogCat并看到以下异常:

01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):尝试向服务器注册时收到异常 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):java.net.SocketTimeoutException:20000ms后无法连接到/10.0.2.2(端口8888) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at libcore.io.IoBridge.connectErrno(IoBridge.java:159) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at libcore.io.IoBridge.connect(IoBridge.java:112) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at java.net.Socket.connect(Socket.java:872) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at libcore.net.http.HttpConnection。(HttpConnection.java:76) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at libcore.net.http.HttpConnection。(HttpConnection.java:50) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at libcore.net.http.HttpConnection $ Address.connect(HttpConnection.java:340) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at libcore.net.http.HttpConnection.connect(HttpConnection.java:128) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at libcore.net.http.HttpEngine.connect(HttpEngine.java:311) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:77) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:964) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at com.googlecloudproject.GCMIntentService.onRegistered(GCMIntentService.java:163) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at com.google.android.gcm.GCMBaseIntentService.handleRegistration(GCMBaseIntentService.java:251) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:153) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在android.app.IntentService $ ServiceHandler.handleMessage(IntentService.java:65) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at android.os.Handler.dispatchMessage(Handler.java:99) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):at android.os.Looper.loop(Looper.java:158) 01-14 06:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在android.os.HandlerThread.run(HandlerThread.java:61)

有人可以建议何时发生此异常,以及为什么我的设备无法注册云端点?

1 个答案:

答案 0 :(得分:4)

我遇到了类似的问题并通过设置

解决了这个问题
LOCAL_APP_ENGINE_SERVER_URL = "http://[myLocalIp]:8888"

其中myLocalIp是您的ipv4地址,您可以从开始菜单中打开cmd.exe并撰写ipconfig来找到该地址。

确保在SERVER_URL中修改正确的CloudEndpointUtils.java字符串。我认为它默认使用LOCAL_APP_ENGINE_SERVER_URL_FOR_ANDROID

为此,我还必须更改后端项目的运行配置。在Eclipse中:选择服务器项目 - >右键单击 - >以 - >运行运行配置。选择Arguments窗格,在Program Arguments中,在--address=0.0.0.0前面添加--port=8888