How to connect your Android app to local instance of Google APP Engine on Android Emulator

Couple of days I am searching for the solution to get the local instance of google app engine to my android app on emulator. This is required as every time you cant deploy the GAE app version to check as its time consuming and not advisable.

To set up this its assumed that you have setup google app engine local instance and your android application

If you are trying, from your Android application through the Android emulator, to access an external service on the same computer (such as your own Google App Engine site) by using the host name localhost or the IP-address 127.0.0.1, you might get a java.net.ConnectException: localhost/127.0.0.1:8888 – Connection refused error – even though you can perfectly well access the service outside the Android application.

 

The reason why a ConnectException occurs is because localhost or 127.0.0.1 inside the Android emulator is the emulator’s own loopback interface, meaning all request sent to the destination will be looped backed to the emulator and won’t actually be sent to your local machine.
To by pass this, simply replace localhost with the IP-address 10.0.2.2as this is a special address towards the real local host.
thats it  and you can now access the your local GAE instance with Android app.
Advertisements

One thought on “How to connect your Android app to local instance of Google APP Engine on Android Emulator

  1. It’s actually a nice and helpful piece of information. I am glad that you just shared this useful info with us. Please stay us informed like this. Thanks for sharing.

What you think ? Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s