0

I'm trying to use googleMaps on an Android Emulator (api23 android 6.0)

GoogleMaps doesn't seem to work when I try to get directions somewhere... it just says "Waiting for Location". I'm wondering: Is it even possible to get myLocation with an Android Emulator? I've read a lot and I'm starting to think "no". I'm starting to consider just giving myLocation some "fake" coordinates and just developing the rest of my app.

Any thoughts?

rikkitikkitumbo
  • 954
  • 3
  • 17
  • 38

2 Answers2

0

I ran into a similar problem some time ago. My quick fix was installing an app called "Fake GPS location" in the emulator. Worked like a charm, and I could set any location I needed by pointing it on the map.

Alfonso
  • 76
  • 2
  • 4
  • To install the app in the emulator, download the apk, start the emulator, and run `adb install app-name.apk` from the command line. – Alfonso Jul 04 '16 at 01:59
0

Based from this thread, you can also connect to the Emulator via Telnet. You then have a Emulator console that lets you enter certain data like geo fixes, network etc.

How to use the console is extensively explained here. To connect to the console open a command line and type

telnet localhost 5554

You then can use the geo command to set a latitude, longitude and if needed altitude on the device that is passed to all programs using the gps location provider. See the link above for further instructions.

The specific command to run in the console is

geo fix <longitude value> <latitude value>

According to the documentation, getLastKnownLocation method can return null. In that case you should wait for location updates (you can user requestLocationUpdates method from LocationManager). You can trigger location update on emulator's gps module by following command: adb -e emu geo fix 50 50.

You should also use LocationManager.GPS_PROVIDER. The emulator may not appear to respond to location changes sent via DDMS when the provider is set to NETWORK_PROVIDER, but will when it is set to GPS_PROVIDER. Check this link.

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59