17

I'm trying to debug the helloword sample on real device. After lots of searching, I've managed to do some settings.

What I did to debug on real device:

  • I've changed LOCAL_APP_ENGINE_SERVER_URL_FOR_ANDROID value to http://192.168.1.107:8888 (my computer ip address)
  • Added --address=192.168.1.107 to run configuration program params so now it looks like --address=192.168.1.107 --port=8888 "<path-to-project>/war"
  • Ran app engine app as web application, server started sucessfuly and I can administrate server app on http://192.168.1.107:8888/_ah/admin/

Unfortunately when I try communicate on real device all i get is:

GoogleJsonResponseException: 500 Failed to retrieve API configs with status: 404

There is full error html content with stack trace attached:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Failed to retrieve API configs with status: 404
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 500 Failed to retrieve API configs with status: 404</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /_ah/api/userendpoint/v1/user/jacek@gmail.com/11224. Reason:
<pre>    Failed to retrieve API configs with status: 404</pre></p><h3>Caused by:</h3><pre>java.io.IOException: Failed to retrieve API configs with status: 404
    at com.google.api.server.spi.tools.devserver.ApiServlet.getApiConfigSources(ApiServlet.java:102)
    at com.google.api.server.spi.tools.devserver.ApiServlet.initConfigsIfNecessary(ApiServlet.java:67)
    at com.google.api.server.spi.tools.devserver.RestApiServlet.service(RestApiServlet.java:117)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:368)
    at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:351)
    at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:97)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:485)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
</pre>
<hr /><i><small>Powered by Jetty://</small></i><br/>   
</body>
</html>

SO it looks like I've communicated with backend, but foor some reason it won't work now. There is no such error when working on localhost and emulator.

Jacek Kwiecień
  • 12,397
  • 20
  • 85
  • 157

3 Answers3

14

Actually just setting --address=0.0.0.0 --port=8888 in launch configuration params fixed the issue.

Rest of the settings stayed as in the question.

Jacek Kwiecień
  • 12,397
  • 20
  • 85
  • 157
  • 1
    setting 0.0.0.0 pretty much tells dev server to accept connections from anywhere, otherwise it probably allows localhost only. – Jacek Kwiecień Dec 05 '13 at 13:57
  • Can you please clarify: where exactly are you making these settings? (I am facing a similar issue [here](http://stackoverflow.com/questions/24378419/debugging-google-web-application-projects-with-google-cloud-endpoints-in-eclipse/24414063#24414063), albeit with an iOS client). – Drux Jun 25 '14 at 23:13
  • 3
    You need to set it in the Run Configuration (in Android Studio open drop down menu to the left of 'Run' button and pick 'Edit configurations', select the one under 'App Engine DevAppServer' and set 'server address' to 0.0.0.0) – gswierczynski Jul 15 '14 at 22:09
1

How can i access my localhost from my android device?

USB doesn't provide network to mobile device. If it's connected to your wifi, then hit your laptop address provided by the router. If it's connected to your mobile network, then first find out your router external IP address, then forward some port to that 10.0.2.2:portno and finally you'll be able to see that server from your device.

You used 192.168.1.107 as your IP, which looks like an internal IP address to me. Try if setting your external IP address fixes the problem.

Community
  • 1
  • 1
Christian Strempfer
  • 7,291
  • 6
  • 50
  • 75
  • It's not a winning answer but since I can't grant the bounty to myself, and the answer is close to the one that helped me... bounty is yours :) – Jacek Kwiecień Dec 05 '13 at 12:36
1

Accepted answer solves the issue. Mentioning steps for deploying GAE from Android studio with screenshots hoping it would save save some more dev time. In Android studio.

  1. Select your Google App engine module.
  2. Then select the dropdown and click in edit configurations
  3. Unselect the check box saying "Synchronize with build.gradle configuration"
  4. In place of server address put "0.0.0.0" (accept all connections).
  5. Select Apply and Ok. Rerun the server.

enter image description here enter image description here

Aniket Thakur
  • 66,731
  • 38
  • 279
  • 289