Android Emulator Development Environment

Sometimes having a physical mobile device is not available when you are doing mobile app development work (even though I strongly recommend it!). When we are faced with that situation, we have no other option but make use of emulators. In this article I want to briefly discuss how to setup an appropriate development environment for Android emulator in order to:

✅ Have the emulator device communicate with a local API server.

✅ Make the GPS work!

Network Connectivity

Unless you are developing a very simple mobile app, chances are that your app needs to connect to an API server. If this is a third party public API server, just move on to the next point, however if you want to setup your own API server, you need a way for the emulator to connect to your localhost.

By default this is not possible, and you need to employ one of the various techniques there are available out there - from tunneling, to using the mighty ngrok, etc. I want to keep this short and give you a solution that will work 100% of the time whether you are using Windows, Linux or OSX:

james@obsidian ~ $ adb devices
List of devices attached
emulator-5554   device

james@obsidian ~ $ adb reverse --list
host-31 tcp:19000 tcp:19000

james@obsidian ~ $ adb -s emulator-5554 reverse tcp:5000 tcp:5000
james@obsidian ~ $ adb reverse --list
host-31 tcp:19000 tcp:19000
host-31 tcp:5000 tcp:5000

So as you can see from above, we are creating a new tunnel that allows the emulator to connect to our API server is listening locally on port 5000. Of course, if your API server is listening on a different port, just change the port number in the code snippet above accordingly.


For some reason, even on recent AVD images, the GPS location on Android emulators will point you to a different country all together - in my case it was some random address near Palo Alto. In order to correctly setup the location of the Android emulator, we need to take a few steps.

  • In the extended controls (the vertical bar on the right hand side of the emulator), go to Location and do the following:
    • Create a single point to your location of choice
    • Click the set location button
    • Make sure the Enable GPS signal button is enabled
  • In the Android settings inside the emulator, go to Location and make sure that Accurate Google GPS Location is enabled as well.
Sometimes even if you follow the above steps (which are also documented by Android), the GPS location won't work well! This is is where most developers give up. Fear not, I have found a solution that works all the time. Simply open the Google Maps app from the Emulator and try to find a location nearby. This will cause the current location GPS to reset and find its bearings, pun intended!

And that is it! Enjoy developing mobile apps on emulators!