【问题标题】:App Engine Connected Android Project: Endpoints server FailedApp Engine 已连接 Android 项目:端点服务器失败
【发布时间】:2013-02-27 11:18:20
【问题描述】:

我是 Android 编程新手,我正在尝试执行一个应用程序,该应用程序将图像发送到返回结果的服务器。出于这个原因,我正在关注 App Engine Connected Android 上的谷歌教程2。 运行应用程序的电话端时出现问题,因为模拟器没有启动,如果我用真实设备尝试它,它会说“使用端点注册失败”,结果的屏幕截图图像在链接中@ 987654322@.

我已将 LOCAL_ANDROID_RUN 设置为 true,并且还插入了相应的项目编号和 api_keys。 不知道怎么回事,控制台和logcat输出如下:

运行 -AppEngine 控制台:

feb. 27, 2013 11:36:51 AM com.google.apphosting.utils.config.EarHelper logNotAnEar
INFO: Directory '/Users/JL/Documents/workspace/p27_2-AppEngine/war' is not an EAR directory. File /Users/JL/Documents/workspace/p27_2-AppEngine/war/appengine-application.xmlappengine-application.xml not detected.
feb. 27, 2013 11:36:51 AM com.google.apphosting.utils.config.EarHelper logNotAnEar
INFO: Directory '/Users/JL/Documents/workspace/p27_2-AppEngine/war' is not an EAR directory. File /Users/JL/Documents/workspace/p27_2-AppEngine/war/appengine-application.xmlappengine-application.xml not detected.
feb. 27, 2013 11:36:51 AM com.google.apphosting.utils.config.EarHelper logNotAnEar
INFO: Directory '/Users/JL/Documents/workspace/p27_2-AppEngine/war' is not an EAR directory. File /Users/JL/Documents/workspace/p27_2-AppEngine/war/appengine-application.xmlappengine-application.xml not detected.
feb. 27, 2013 11:36:51 AM com.google.apphosting.utils.config.EarHelper logNotAnEar
INFO: Directory '/Users/JL/Documents/workspace/p27_2-AppEngine/war' is not an EAR directory. File /Users/JL/Documents/workspace/p27_2-AppEngine/war/appengine-application.xmlappengine-application.xml not detected.
feb. 27, 2013 11:36:51 AM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed /Users/JL/Documents/workspace/p27_2-AppEngine/war/WEB-INF/appengine-web.xml
feb. 27, 2013 11:36:51 AM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed /Users/JL/Documents/workspace/p27_2-AppEngine/war/WEB-INF/web.xml
feb. 27, 2013 11:36:51 AM com.google.appengine.tools.development.SystemPropertiesManager setSystemProperties
INFO: Overwriting system property key 'java.util.logging.config.file', value '/Applications/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.5/appengine-java-sdk-1.7.5/config/sdk/logging.properties' with value 'WEB-INF/logging.properties' from '/Users/JL/Documents/workspace/p27_2-AppEngine/war/WEB-INF/appengine-web.xml'
java.net.BindException: Address already in use
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:344)
    at sun.nio.ch.Net.bind(Net.java:336)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:199)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.mortbay.jetty.nio.SelectChannelConnector.open(SelectChannelConnector.java:216)
    at com.google.appengine.tools.development.JettyContainerService.connectContainer(JettyContainerService.java:189)
    at com.google.appengine.tools.development.AbstractContainerService.createConnection(AbstractContainerService.java:243)
    at com.google.appengine.tools.development.AbstractServer.createConnection(AbstractServer.java:71)
    at com.google.appengine.tools.development.DevAppServerImpl$Servers.createConnections(DevAppServerImpl.java:445)
    at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:181)
    at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:333)
    at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
    at com.google.appengine.tools.development.DevAppServerMain.<init>(DevAppServerMain.java:269)
    at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:245)

在真实设备上运行手机端 控制台:

[2013-02-27 11:31:53 - p27_2] ------------------------------
[2013-02-27 11:31:53 - p27_2] Android Launch!
[2013-02-27 11:31:53 - p27_2] adb is running normally.
[2013-02-27 11:31:53 - p27_2] Performing com.p27_2.MainActivity activity launch
[2013-02-27 11:31:56 - p27_2] Application already deployed. No need to reinstall.
[2013-02-27 11:31:56 - p27_2] Starting activity com.p27_2.MainActivity on device 31315808870300EC
[2013-02-27 11:31:56 - p27_2] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.p27_2/.MainActivity }
[2013-02-27 11:31:56 - p27_2] ActivityManager: Warning: Activity not started, its current task has been brought to the front
[2013-02-27 11:35:21 - p27_2] ------------------------------
[2013-02-27 11:35:21 - p27_2] Android Launch!
[2013-02-27 11:35:21 - p27_2] adb is running normally.
[2013-02-27 11:35:21 - p27_2] Performing com.p27_2.MainActivity activity launch
[2013-02-27 11:35:24 - p27_2] Application already deployed. No need to reinstall.
[2013-02-27 11:35:24 - p27_2] Starting activity com.p27_2.MainActivity on device 31315808870300EC
[2013-02-27 11:35:24 - p27_2] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.p27_2/.MainActivity }
[2013-02-27 11:35:24 - p27_2] ActivityManager: Warning: Activity not started, its current task has been brought to the front
[2013-02-27 11:37:06 - p27_2] ------------------------------
[2013-02-27 11:37:06 - p27_2] Android Launch!
[2013-02-27 11:37:06 - p27_2] adb is running normally.
[2013-02-27 11:37:06 - p27_2] Performing com.p27_2.MainActivity activity launch
[2013-02-27 11:37:09 - p27_2] Application already deployed. No need to reinstall.
[2013-02-27 11:37:09 - p27_2] Starting activity com.p27_2.MainActivity on device 31315808870300EC
[2013-02-27 11:37:10 - p27_2] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.p27_2/.MainActivity }
[2013-02-27 11:37:10 - p27_2] ActivityManager: Warning: Activity not started, its current task has been brought to the front

LogCat:

02-27 11:36:58.968: D/GCMRegistrar(1684): resetting backoff for com.p27_2
02-27 11:36:58.968: V/GCMRegistrar(1684): Registering app com.p27_2 of senders 658829472559
02-27 11:36:59.296: V/GCMBroadcastReceiver(1684): onReceive: com.google.android.c2dm.intent.REGISTRATION
02-27 11:36:59.296: V/GCMBroadcastReceiver(1684): GCM IntentService class: com.p27_2.GCMIntentService
02-27 11:36:59.296: V/GCMBaseIntentService(1684): Acquiring wakelock
02-27 11:36:59.316: W/AbstractGoogleClient(1684): Application name is not set. Call Builder#setApplicationName.
02-27 11:36:59.328: D/GCMBaseIntentService(1684): handleRegistration: registrationId = APA91bEN9AXnKP8jsVmt3fNj1ziAegl04m4laECFqkzFxbuk2dfdvK3ePCVH_3JOjKehC0EpPgkkIp8t-OJtxTe_E12lw9atzEcHVpsyr_Qdi4UYxQgsW2w3uZQRnbj8Aho_IUjAWKub, error = null, unregistered = null
02-27 11:36:59.328: D/GCMRegistrar(1684): resetting backoff for com.p27_2
02-27 11:36:59.335: V/GCMRegistrar(1684): Saving regId on app version 1
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684): Exception received when attempting to register with server at http://10.0.2.2:8888/_ah/api/
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684): java.net.SocketTimeoutException: failed to connect to /10.0.2.2 (port 8888) after 20000ms
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at libcore.io.IoBridge.connectErrno(IoBridge.java:159)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at libcore.io.IoBridge.connect(IoBridge.java:112)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at java.net.Socket.connect(Socket.java:842)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:341)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:188)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:80)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1009)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:407)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:340)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:458)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at com.p27_2.GCMIntentService.onRegistered(GCMIntentService.java:169)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at com.google.android.gcm.GCMBaseIntentService.handleRegistration(GCMBaseIntentService.java:251)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:153)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at android.os.Looper.loop(Looper.java:137)
02-27 11:37:39.511: E/com.p27_2.GCMIntentService(1684):     at android.os.HandlerThread.run(HandlerThread.java:60)
02-27 11:37:39.523: V/GCMBaseIntentService(1684): Releasing wakelock
02-27 11:37:39.562: D/dalvikvm(1684): GC_CONCURRENT freed 134K, 7% free 8586K/9159K, paused 18ms+7ms, total 70ms

非常感谢。

【问题讨论】:

  • 你的服务器好像没有运行....重启服务器试试
  • 嗨@Ajit,非常感谢您的回答。我已经重新启动了eclipse并运行了几次服务器代码,但结果是一样的。现在我找到了这个 [post] [1],但是答案提供的链接对我不起作用(当然,从 Google API 控制台更改项目编号的“YOUR-APP-ID”)。 [1]:stackoverflow.com/questions/15047744/…

标签: java android google-app-engine


【解决方案1】:
  1. 确保在 CloudEndPointUtils 类中将常量 LOCAL_ANDROID_RUN 设置为 false,这意味着我们的服务器未在本地设置。
  2. 通过右键单击项目->google->部署到应用引擎,将您的 -AppEngine 项目部署到 google appEngine。
  3. 将部署到 CloudEndPints.java 后显示的 url 添加到变量为 LOCAL_APP_ENGINE_SERVER_URL

【讨论】:

    【解决方案2】:

    您的错误 java.net.BindException: Address already in use 表示本地 AppEngine 实例未正确启动。通常,当我尝试启动本地 GAE 实例时,当另一个 GAE 实例已经将自己绑定到端口(即我启动它两次)时,我会看到此错误,但在这种情况下,您的 Android 应用程序应该与第一个实例通信并且仍然功能。

    您的问题有所不同——出于某种原因,您的 initial GAE 实例无法将自身绑定到端口(我们知道这一点是因为 Android 应用无法找到任何本地 GAE 实例)。我会按顺序尝试以下方法,直到它起作用:

    1. 确保您的 GAE 运行配置设置为绑定到端口 8888(如果端口设置为 1024 或以下,操作系统可能会拒绝绑定尝试)。
    2. 假设您使用 Eclipse,请将您的 GAE 运行配置更改为“自动选择未使用的端口”并查看它是否可以正常启动。如果是,则将此端口设置为在您的 GAE 运行配置和 Android 应用程序中使用的端口。如果这解决了它并且您很好奇,您可能想看看已经绑定到端口 8888 的内容。
    3. 找到一个绝对没有绑定任何东西的端口(1024 以上),然后在您的 GAE 运行配置中尝试。
    4. 如果你到了这一步,你将无法绑定到任何端口,这很奇怪。如果涉及到这个,请回信=)

    【讨论】:

      【解决方案3】:

      我遇到了同样的问题:使用 eclipse android 应用引擎连接项目,在具有 localhost 后端的模拟器上注册云端点服务器成功,而在部署了应用引擎后端的设备上运行时失败。在清除设备上的缓存并搜索答案 3 小时后,我执行了以下对我有用的操作,现在设备上的云端点注册成功,我可以将 GCM 发送到我的设备。

      1. 右键单击客户端项目>android工具>添加支持 图书馆
      2. 右键单击服务器端项目> google > 生成云端点客户端库
      3. 从手机中删除应用并清除手机缓存(对于 Galaxy nexus 果冻豆:设置 > 存储 > 点击缓存数据)
      4. 确保服务器当前未在您的本地主机上运行
      5. 从您的计算机重新安装应用程序,因为您刚刚更新了支持库

      希望有帮助!!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-15
        • 1970-01-01
        • 2012-05-04
        • 1970-01-01
        • 2017-09-10
        相关资源
        最近更新 更多