Not working on Android devices
$ ionic cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION="To locate you" $ npm install --save @ionic-native/geolocation
I used the above plugin referred in https://ionicframework.com/docs/native/geolocation/ But I am not getting the cureent location on android devices.Many people have the same issue
https://forum.ionicframework.com/t/ionic-get-current-location/118168/6 tried using running the app using prod flag dint help.
please help me
The same for me, the plugin doesn't work
The same for me, on Android doesn't work
Same problem for me, plugin not working on Android 8.0 Tested on app using watchPosition function and latest version of plugin. Works fine on all devices up to Android 7.0 ( not tested on 7.1). On two different devices with android 8.0 watchPosition start fine then stops after 120 seconds.
Correct, stopped working on Android Oreo.
Not working for me either
Same for me on Oreo and Kit Kat also
Is this plugin getting updated for android 8.0 or do we have to move on?
Working fine for me on 8.0, and 8.1 devices.
However, I am experiencing intermittent timeout issues on some devices (which all happen to be Samsungs -- but not every samsung has issues).
I suspect that it's a permission/system issue related to Samsung's mangling of android OS. Try opening google maps, acquiring position, and then try again. Obviously, this is not a fix, but I don't think the blame sits with this library.
@davidgovea
I have experienced this issue in MI A1,and tab ,I am not getting the current location.I tried high accuracy settings but no use.I dont know how you are able to get the location on phone. When I run ionic serve and check on the console I am getting the location But not in Android hardware devices .
Same issue. It's intermittently on S9 and Note 8 devices.
Same here.... On getCurrentPosition I never receive a callback.... If I go to mobile location settings and set the location method from "mobile only" to "High Precision" it resolves the problem.....
But when I try to do:
this.geolocation.getCurrentPosition( {enableHighAccuracy: true}).then(callback => {.....})
I never receive the callback.......
iOS works fine for me.
Same issue. I never receive the callback.
Thanks for supporting all. It is very urgent can this issue will be fixed or we have to move on?.
+1
Has anyone created a pure Cordova reproduction of the error yet as a Github repository? If not, please one of you having the issue do so (start with cordova create, commit to a Github repository) and document all the commands you execute and changes you do and commit each step individually so it is easy to follow. Then post the URL here, then it is easier for someone to reproduce.
What exact versions of Android are affected? What exact devices are affected? Is the issue reproducible in an emulator?
@janpio try to reproduce on Samsung Galaxy S7 - Android 8.0.0
This is the device model that I use to test my app. You will probably get the same issue on this device.
If you're experiencing this issue, make sure you are providing the timeout option to your geolocation call, e.g. getCurrentPosition(successFn, errorFn, { timeout: 10000 });
This way, failing devices can be handled in the same way as a user who declines location permissions (which your app should already do), instead of hanging.
I would say it's an extremely good bet that this issue will be resolved, but perhaps not in the timescale that you would prefer. If the issue is highly urgent, I might suggest the following approaches for your consideration (ranked from helpful to not-so-helpful):
- Create a reproduction project as @janpio has suggested
- Invest some time into fixing/updating this free, open-source code
- Provide more testing anecdotes and +1's to this thread
- Find a different approach ("move on")
- Motivate the contributors by threatening (or even just bluffing) to "move on" 😉
Tested with Android version 6.0
git clone [email protected]:vwasteels/test-cordova-geolocation.git
cd test-cordova-geolocation
cordova prepare
cordova run android --device
open inspector at chrome://inspect console says, after 10 seconds :
Received Event: deviceready
getCurrentPosition fails
PositionError {code: 3, message: "Timeout expired"}
Thanks @vwasteels!
I have a Google Nexus 5, running Android 6.0.1 (October 5, 2016 security patch level). I cloned your repo, run the commands and tested on that device. On startup I got the usual question for location permission, which I of course agreed. Then in chrome://inspect it successfully receives my location:

(The repo uses Cordova Android 7.0.0 by the way. You might want to try to upgrade the platform to 7.1.1 with cordova platform rm android then cordova platform add [email protected] - although I don't expect this to change anything.)
So I can't reproduce on my Android 6.x device.
@janpio thanks for testing, I also tried upgrading cordova-android, but it doesn't change anything. and I was also prompted for location permission.
Can you guys test my repo with your device and log the result here ?
thank you