18

I have a project in which I need to get the location as India. But in my emulator I am not getting the location.

  • I need to get the location as India
  • when I take the google maps from my emulator, it is showing the current location in middle of the sea.

    API level I am using is 27.
    Emulator I use is Nexus 5x.
    

how to get the current position in this Emulator and also manually.

I tried to edit the location in Emulator and tried to give the latitude and longitude but it is not working.

Dhruv Patel
  • 1,529
  • 1
  • 18
  • 27
Martin j
  • 511
  • 1
  • 9
  • 31
  • You can find the answer [here](https://stackoverflow.com/questions/2279647/how-to-emulate-gps-location-in-the-android-emulator) – jorjSB Nov 28 '17 at 09:31
  • Check these Links https://stackoverflow.com/questions/38247350/emulators-location-simulation-not-working https://stackoverflow.com/questions/39204953/mock-location-does-not-work-in-android-studio-emulator https://stackoverflow.com/questions/18972114/set-gps-location-in-emulator-using-android-studio – Tomin B Azhakathu Nov 28 '17 at 09:31

7 Answers7

26

First of all,

  • Restart your emulator.
  • Go to More > Location. Enter your lat-long > Press SEND

enter image description here

Dhruv Patel
  • 1,529
  • 1
  • 18
  • 27
  • 9
    tried that many times.. doesn't works, after setting it when i look at google map its still says the current location is in america – Martin j Nov 28 '17 at 13:02
  • 1
    As of this writing, those location controls no longer exist in Android Studio Dolphin | 2021.3.1 Patch 1. – Mike S. Oct 20 '22 at 17:02
25

In 2020 with Android Studio 3.6, the way I had to change the emulator location is slightly different than accepted answer. Here how it is:

First,

click more on emulator

Second, Location is first menu item and it is selected by default. You have to select your location in the map and save that point.

tap on map and set your location point

Third, select the saved point and press on select location button in bottom right corner.

change emulator location

That's it, close that window. You are all done.

Sometimes you may have to close the emulator and open (Not restart).

Blasanka
  • 21,001
  • 12
  • 102
  • 104
4

You can set Location using Command prompt or ADB

Set permissions in AndroidManifest.xml:

Find the correct local port for your Android emulator:

$ adb devices
  List of devices attached
  emulator-5554 device

The port we are looking for is in this case 5554. Now connect via telnet:

$ telnet localhost 5554
  Trying::1...
  Trying 127.0.0.1...
  Connected to localhost.
  Escape character is '^]'.
  Android Console: type 'help' for a list of commands

Set your preferred location manually: You set the location with the geo fix command:

 geo fix $longitude $latitude

For Example

geo fix 2.169919 41.387917
OK

ANOTHER EASY WAY

Open Android Device Monitor From Android Studio.

Select the Emulator.

Select Emulator Control

In Emulator Control Select Location Control

Select Manual

In that Give your Longitude and Latitude

Tomin B Azhakathu
  • 2,656
  • 1
  • 19
  • 28
  • 2
    when i tried to give the command - geo fix 2.169919 41.387917 , iam getting error:- Android Console: Authentication required Android Console: type 'auth ' to authenticate Android Console: you can find your in 'C:\Users\martin\.emulator_console_auth_token' OK - what to do with this error @Tomin B – Martin j Nov 28 '17 at 10:45
  • 1
    @Martinj Try the next method. Using Android Device Monitor. Second Method will Work for Sure – Tomin B Azhakathu Nov 28 '17 at 11:18
  • when i clicked the android device monitor nothing comes – Martin j Nov 28 '17 at 13:00
  • the ADM has everything grayed out for emulator control. the emulator lets you type and press buttons with gps coords, but it has no affect – FirefighterBlu3 Feb 23 '18 at 04:23
  • @Martinj Ops forgot to say that you also need to restart emulator. Did you? – Blasanka Aug 14 '20 at 18:36
4

In my case; until i login my Google account on emulator, location not changed. After login, it's changed. I think it's about Google Services.

Mete
  • 2,805
  • 1
  • 28
  • 38
0

In my case, setting the point and restarting the emulator, then signin in to Google account and checking my location in Chrome directly was the solution.

0

I solved this by wiping the emulator's data and restarting it.

-1

set force Android Location Manager to true. Like this "position = await Geolocator.getCurrentPosition( desiredAccuracy: LocationAccuracy.low, forceAndroidLocationManager: true);" then you will get the location on emulator.

Guhan
  • 21
  • 2