Skip to content

Geolocation and the Android 2.3.3 emulator

Just so someone else doesn’t waste an afternoon banging their head against a wall, here’s how to make the Android 2.3.3 emulator work if you want to access geolocation.  This applies to the javascript apps I’m writing–I don’t know if a native app would have the same issue.

  1. Install an Android 2.2 AVD (2.3.3 doesn’t work with geolocation).  Make sure you enable the GPS in your hardware settings when setting up the AVD.  That’s right, the first step to making the Android 2.3.3 emulator work is to downgrade to Android 2.2.  Why would you want to target 2.3.3+?
  2. Make sure you add <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION” /> to your Android manifest.
  3. Add <uses-feature android:name=”android.hardware.location.gps” android:required=”false” /> just to be sure.
  4. Start your emulator and install your software.
  5. telnet localhost 5554 (if you don’t have telnet installed on Windows 7, here’s how to enable it).
  6. In the telnet window, type in “fix geo -101 50”.  Note that you can’t use the backspace, so cutting and pasting is your best option.  Also note that longitude is before latitude.
  7. Execute the action that requires a geolocation.  (If using phonegap, make sure to pass these options to the geolocation call: { enableHighAccuracy: true }.)

You should see a GPS satellite in the notification bar of your emulator.

Also, note that each time you execute the action that calls the geolocation service of your phone, you have to type the ‘fix geo…’ line in the telnet session.

I also found this page useful for testing.