Google App Engine with Android - testing endpoints on real device

If you want to do this in Android Studio, set httpAddress as follows in your build.gradle

appengine {

  ...

  httpAddress = "0.0.0.0"
}

To accomplish this

  1. Put LOCAL_APP_ENGINE_SERVER_URL_FOR_ANDROID = your IP address (this is in your android App)
  2. Right click on App-Engine project -> Run-> Run Configurations -> Web Application(left bar) -> your app-engine project.

2.(Contniued) Go to Arugments -> add exactly like this

--address=0.0.0.0 --port=.......

*to get your ip address, go to cmd -> ipconfig -> add (IPV4 address with port number) in step 1

important note: Please change this everytime in case you are accessing internet from dongle or some dynamic IP internet service

Thankyou ... this works perfectly


There are many answers here but I've found them messy or uncomplete. To run the local server on your computer and test it with a real device do this:

1) Add httpAddress = "0.0.0.0" to the appengine block in your build.gradle file of the backend (Google Cloud Endpoint) module, like this:

appengine {
    ...
    httpAddress = "0.0.0.0"
}

According to a comment on the question this means that 'will accept from anywhere'.

2) Run your backend module locally (ie. start the web server). This is trivial: select the backend configuration on the drop-down menu and press the green button. You can find more detailed instructions here.

You should now be able to open a browser (on your computer) and navigate to http://localhost:8080/ and see a webpage with 'Hello, Endpoints!' and many other stuff.

3) Find your computer's IP address (on a Mac go to System Preferences -> Network) and then set it as the root url in your Android app code, like this:

MyApi.Builder builder = new MyApi.Builder(
                            AndroidHttp.newCompatibleTransport(),
                            new AndroidJsonFactory(), 
                            null
).setRootUrl("http://192.168.1.36:8080/_ah/api/")

That's all!