-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geolocation 'enableHighAccuracy' on Android always times out #7495
Comments
@acapop77 Forgot to mention also that permissions are enabled using:
|
I have same problem on RN 0.25.1, difference is, for me problem persists for high and low accuracy. Finally I found something that makes it work, but is not a solution. Here is what worked for me - assuming that you use stock android avd - emulator:
This works for me - on 'one time only base'. Each time I want to reload app I need to go 3-4 steps again. But at least this way I get Geolocation to work, and do not get timeout error. |
I'm experiencing something similar in 0.24. Even though "Looks like the app doesn't have the permission to access location. Add the following line..." I am not using the emulator and instead building directly to the device. Edit - this also happens in 0.25.1 |
@acapop77 @rossthedevigner I'm also building directly to a Samsung S6 device. |
@Findiglay Same here. I even tried doing a manual .apk install and I still received the error. I'm trying a workaround where I loop through the permissions manifest and see if |
Anyone having navigator.geolocation == undefined? I am currently having this issue on my device. |
There are various issues being reported here. I'm not sure that all are relevant to the specific issue with enableHighAccuracy. I don't have any experience with android development, but I've found that if I edit LocationModule.java to hardcode the LocationOptions Could this mean the bug is happening in the bridge between the Geolocation API & the LocationModule? |
I am experiencing the same problem. I did the same as @Findiglay suggested and worked for a few times, but then I got only timeouts. Any idea why this happens on real devices? :( |
Having the same issue. I'm currently running the app on real devices, using RN 0.25.1. I should add that I have already added the necessary Android permissions to the permissions manifest. But still timeouts. |
as a workaround, I enabled 'Allow mock locations' in android settings and installed an app that mocks the gps (look for fake gps in store). At least until this is fixed, development is not blocked |
I guys, If you execute tests "inside your office" using physical device, the GPS locator can be disturbed by external things like walls, or by the simple reason that you are trying to do this operation "indoor" and, generally, this should be executed outdoor. Well, after this we go outside from our office, we re-execute the tests and the device responds as planned (we don't received the Request timed out error). My suggestion is: try geolocation using "enableHighAccuracy" set to true, if this fail (in the office this can fail), retry with false, this should work, in my case it did. Hope this can helps. |
This comment has been minimized.
This comment has been minimized.
Same issue here whether
|
setting |
Same problem here with LGE Nexus 5 (Android 6.0). |
Hey guys, I've found temporary fix - this package https://github.com/lucasferreira/react-native-android-permissions |
Any updates or fix for this? Everything works fine on Simulator and pre 5.0 devices, after that only timeout, and I desperately need a fix for an already available app! |
+1 |
This issue is affected by the locationMode setting on the device. When location mode is set to either high accuracy or device only, geolocation times out. It works correctly when location mode is set to battery saving |
I've had the same problem, I took a punt and removed the 3rd argument. And its now working.
|
I'm assuming this is related to: https://productpains.com/post/react-native/add-android-m-permissions-model-support right? |
No that was for the location timeout issue |
Yes I had just discovered removing the 3rd argument seems to be a fix. We haven't fully device tested yet but it seems that android version 22, with device mode set to either high accuracy or device only, will cause the cause the location to timeout, when the 3rd argument is included regardless of settings. It seems to not affect android version 23. |
Same experience my side, except android version 23 only works with the 3rd argument when |
Removing the 3rd argument just make me have the popup of "Location request timed out" instantly instead of waiting the until the timeout is done. Setting On my emulator, the Location is only available when i open the emulator settings and send a location (check the screenshot). Is there a way to get it automatically? |
In my case setting |
Having the same problem here, both on emulator and on device, and tried with both true and false for enableHighAccuracy |
I just outright get "undefined is not an object (evaluating 'navigator.geolocation.getCurrentPosition')" I tried checking if(navigator), that returned true, Also, doing this on device on Android 5.1 OnePlus One. Developer mode enabled, AndroidManifest permissions included, mock locations on/off, everything. |
Hi I was facing same issue "request time out " I have tried every possible solution as given above those could not work for me but recently I found one module which overcomes this problem. |
@vishalTechnoFreek , also exists react-native-cross-geolocation. It is fully compatible with the current RN geolocation, but using the new Google API. With this API you don't worry which mode to use, the service automatically detects the best option. Another advantage is that, when RN corrects this problem, you can remove it without affecting your app, if you wish. |
For my case what mentioned @manurana about (downloading and) opening the Google Maps app and then go back to Expo did the trick. I'm working with Genymotion and Android 5. Also, for Genymotion users, for properly reading the position the Genymotion's map window must be opened; otherwise it'll work but with the default Geny's location |
lifesaver 👍 this worked for me. |
I'm facing the same problem, but setting |
I faced similar problem with multiple requests (continuously selecting use current location ) I have added retry for the location request. not the exact problem but may be will help somebody.
|
https://www.npmjs.com/package/react-native-geolocation-service |
Hi, Guest I solve the mistery, what happend is that when we ask for the location the first time and use "maximunAge" we dont have a previous location cached so, there are a bug, be sure that the very first time when ask for location is with no "maximunAge" |
the simple answer is to step out of where you are and go to open space then try again. Its simple science. GPS services are affected by thick walls and cars. This worked for me. No need to edit anything !!! |
Thank you very much! Work! |
Hi, Do anyone have any workaround to solve this issue. Thanks |
@akhilsanker maybe try a library like react-native-fused-location |
Hi @reyalpsirc , Thanks for the reply. Really appreciate for your time. Thank you. |
Sorry @akhilsanker, all I did was to use react native's Geolocation for iOS and FusedLocation for Android. |
setting |
Geolocation module is removed from RN in master, and won't be available in 0.60. Please use https://github.com/react-native-community/react-native-geolocation and report issues there. Thank you |
It's 2019, tried 3 different locational libraries none of them work for Android. Amazing. |
react-native-geolocation-service is working fine. If a package is not working, create an issue ticket on that repo. Issues won't fix themselves, join the community. |
see iwangsyah's comment. I needed both the |
Thank you! |
Developing an Android app, whilst debugging on my Android Device running on 6.1, the geolocation api always returns an error callback with the message
Location request timed out
.If I toggle enableHighAccuracy option to false, the api works fine. In high accuracy mode, the timeout always takes as long as I specify in the timeout option i.e. 20 seconds.
I've tried running with dev mode turned off.
Should high accuracy mode work in Android?
The text was updated successfully, but these errors were encountered: