2

First of all I'll let you know that this question solves a part of my problem but not all of it:

Emulator's Location simulation not working

I managed to have the emulator's location provider to work (verifying it using the Google Maps App) but it is my React Native app the one that is not getting the location. It does on a real device so I would say it is more of an issue between the app and the emulator.

So as I said, I'm getting this location in the Google Maps App:

enter image description here

My Emulator specs:

enter image description here

What I'm doing in my React App is the following:

In a React async action: (Works on real device)

return navigator.geolocation.getCurrentPosition(
  (position) => {
    let initialCenterPosition = {
      latitude : position.coords.latitude,
      longitude : position.coords.longitude
    }

    dispatch(requestInitialCenterPositionSuccess(initialCenterPosition))
  },
  (error) => {
    dispatch(requestInitialCenterPositionError(error))
  },
  {enableHighAccuracy: true, timeout: 10000, maximumAge: 0}
)

And the current permissions in my Android Manifest XML just in case:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

My Sdk and Build Tools versions in the build.graddle file:

compileSdkVersion 23
buildToolsVersion "23.0.3"

Also tested it with builtToolsVersion : "24.0.2"

Switching the enableHighAccuracy to false in the getCurrentPosition function won't do any change.

Is there another aspect I should be aware off in my React Native app specs so this could work? It does seem weird to me that I don't have any trouble on the real device

Thanks to all

Community
  • 1
  • 1
José Del Valle
  • 691
  • 1
  • 13
  • 27

2 Answers2

3

Set is enableHighAccuracy false, the problem will be solved

{enableHighAccuracy: false, timeout: 10000, maximumAge: 0}
Burak Demirezen
  • 545
  • 6
  • 12
0

you should restart in your device after changing location settings.