question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getCurrentLocation timeout and watchPosition not working with Android Emulator

See original GitHub issue

I just upgraded to Android Studio Arctic Fox 2020.3.1 and Android Emulator 30.7.5, and am now having trouble getting a GPS position returned within the emulator. I’m running Android Studio in Linux, although I’m not sure that matters.

I appear to have all permissions granted, in that the Location permissions show under Location settings in the emulator and a copy of hasLocationPermissions() from the example app returns true. I’ve set the timeout quite high (20 seconds), and am never getting a value back. I have also added a position watch and nothing seems to come back from there.

adb logcat doesn’t appear to show anything interesting related to the GPS from what I can tell. No obvious errors are spit out to react native or logcat while starting up the app.

I’m not sure where else exactly I should be looking to try to debug this issue.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
aardvarkkcommented, Aug 3, 2021

So the issue turns out to be that the default value of PRIORITY_BALANCED_POWER_ACCURACY for the accuracy just… doesn’t work in the emulator? I just happened to try it in my native testing code and swapped over to that value from the values I had inserted based on the Android tutorials for setting up a location request, which instruct you to use PRIORITY_HIGH_ACCURACY.

After switching my native code test to use the balanced settings, I got the same isLocationAvailable: false value. Just changing my RN-level code to request accuracy: { android: 'high' } fixed all of the problems I was seeing.

My only recommendation from this bug would be to perhaps throw a warning/error if isLocationAvailable is false, even if isLocationEnabled is true. I will leave it open for the time being in hopes other people may find it if they run into the same weird issue.

0reactions
leonidlewiscommented, Dec 9, 2022

I can fix it

On Thu, Dec 8, 2022 at 12:27 PM Efstathios Ntonas @.***> wrote:

cross posting this here just in case someone want to test this possible fix: #174 (comment) https://github.com/Agontuk/react-native-geolocation-service/issues/174#issuecomment-1343015525

— Reply to this email directly, view it on GitHub https://github.com/Agontuk/react-native-geolocation-service/issues/296#issuecomment-1343057710, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT3NYX5PXKZ6FIYAPSES6VDWMILAVANCNFSM5BPLOHGQ . You are receiving this because you commented.Message ID: @.*** com>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Emulator having issues with Geolocation
You have to put enableHighAccuracy into getCurrentPosition, for example: navigator.geolocation.getCurrentPosition(onSuccess, onError, { maximumAge: 3000, ...
Read more >
Location - Expo Documentation
Open Android Studio, and launch your AVD in the emulator. Then, on the options bar for your device, click the icon for "More"...
Read more >
Geolocation - tutorials - Ionic Forum
I try to develop an Ionic app with android platform using ngCordova geolocation. I just want to get the user location (latitude and...
Read more >
Geolocation.watchPosition() - Web APIs | MDN
An optional object that provides configuration options for the location watch. See Geolocation.getCurrentPosition() for more details on possible ...
Read more >
geolocationOptions - Apache Cordova
{ maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }; ... Android 2.x emulators do not return a geolocation result unless the enableHighAccuracy ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found