cordova-plugin-geolocation icon indicating copy to clipboard operation
cordova-plugin-geolocation copied to clipboard

Not working on Android devices

Open sachinGAcharya opened this issue 8 years ago • 102 comments

$ 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

sachinGAcharya avatar Sep 05 '18 11:09 sachinGAcharya

The same for me, the plugin doesn't work

JaviRpo avatar Sep 05 '18 15:09 JaviRpo

The same for me, on Android doesn't work

SimonSoft93 avatar Sep 07 '18 10:09 SimonSoft93

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.

alessandrobarbetti avatar Sep 07 '18 10:09 alessandrobarbetti

Correct, stopped working on Android Oreo.

battika avatar Sep 07 '18 19:09 battika

Not working for me either

natedl98 avatar Sep 08 '18 18:09 natedl98

Same for me on Oreo and Kit Kat also

lumitor2 avatar Sep 10 '18 14:09 lumitor2

Is this plugin getting updated for android 8.0 or do we have to move on?

ArGaspar avatar Sep 11 '18 23:09 ArGaspar

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 avatar Sep 12 '18 01:09 davidgovea

@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 .

sachinGAcharya avatar Sep 12 '18 08:09 sachinGAcharya

Same issue. It's intermittently on S9 and Note 8 devices.

vancuren avatar Sep 13 '18 03:09 vancuren

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.

fernandoocf avatar Sep 13 '18 20:09 fernandoocf

Same issue. I never receive the callback.

marteagam avatar Sep 14 '18 03:09 marteagam

Thanks for supporting all. It is very urgent can this issue will be fixed or we have to move on?.

sachinGAcharya avatar Sep 14 '18 04:09 sachinGAcharya

+1

vwasteels avatar Sep 14 '18 15:09 vwasteels

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 avatar Sep 14 '18 15:09 janpio

@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.

fernandoocf avatar Sep 14 '18 18:09 fernandoocf

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):

  1. Create a reproduction project as @janpio has suggested
  2. Invest some time into fixing/updating this free, open-source code
  3. Provide more testing anecdotes and +1's to this thread
  4. Find a different approach ("move on")
  5. Motivate the contributors by threatening (or even just bluffing) to "move on" 😉

davidgovea avatar Sep 14 '18 21:09 davidgovea

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"}

vwasteels avatar Sep 14 '18 21:09 vwasteels

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:

image

(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 avatar Sep 15 '18 16:09 janpio

@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

vwasteels avatar Sep 17 '18 07:09 vwasteels