Timeout exception Android 8+9 (v2.4.3), Android 8 (v4.0.1)
I got timeout exception when try to get location. I have no errors with previous android versions.
So you think there is a new bug/problem with Android 9? Is this reproducible on different devices? What is the minimal code to reproduce this behaviour?
Yes, I think it's a problem with Android 9 because the app has been tested with other versions of android without problems. I tried with an emulator and physical device (pixel).
cordova-plugin-geolocation 4.0.1
same here to nexus6 with android 7 pixel with android 8
testGeo = () => {
alert('try')
get(navigator, 'geolocation.getCurrentPosition') && navigator.geolocation.getCurrentPosition(resp => {
alert(JSON.stringify(resp, null, 2));
}, err => {
alert(JSON.stringify(err, null, 2));
}, {
enableHighAccuracy: true
});
}
works on ios but not android
add
timeout: 2000, maximumAge: 3000,
doesn't work too
<body>
<button onclick="javascript: navigator.geolocation.getCurrentPosition(resp => {
alert(1)
alert(JSON.stringify(resp, null, 2));
}, err => {
alert(2)
alert(JSON.stringify(err, null, 2));
}, {
enableHighAccuracy: true,
timeout: 2000,
maximumAge: 3000,
})">test32111</button>
</body>
I made a little app just for testing that problem. With the version 2.4.3 I get timeout exception on android 8 but works fine on android 6. The function:
getCurrentPosition() {
return new Promise(function (resolve, reject) {
function onSuccess(position) {
alert('latitud : ' + position.coords.latitude);
alert('longitud : ' + position.coords.longitude);
resolve([position.coords.latitude, position.coords.longitude]);
};
function onError(error) {
alert('Error getCurrentPosition : ' +
'code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
reject("KO");
};
navigator.geolocation.getCurrentPosition(onSuccess, onError, { timeout: 30000 });
});
}
Edit: 2.1.0 version works fine on android 8.0.0 and before but still not working on android 9.
@llinaresvicent So you are saying it is not only Android 9 but also Android 8 that is broken?
@janpio "yes". It's broken the last version of the plugin (2.4.3) for Android 8 and for Android 9. Trying to fix it for my project I installed older versions of the plugin and it worked with 2.1.0 version for Android 8 but not for 9. Look at "Edit:" on last line.
I changed the title to reflect that.
Ok, after testing on other devices and with an app that only takes your location I can confirm the plugin works on Android 9 too but with 2.1.0 version. I think the issue should remain still opened because it doesn't work properly on the last version. @crapthings, check if works for you with 2.1.0 version.
Hi, I've the same issue. Cordova: 8.0.0 Android platform: 6.4.0 I tried many times with all configs and all time i get Timeout exception on 2 devices with Android 6 and 7. I tried with latest version (4.0.1) and with 2.4.3 version but i still get the error
@SimonSoft93 If you are using Android 6 and 7, you definitely don't have the "same problem" as this is about Android 8 and 9.
Also you are not using the newest cordova-android, so this problem might be caused by this.
I have: android 8.0.0 cordova 8.0.0 cordova-android 6.4.0
plugin settings: timeout: 30000 maximumAge: 39600000 highAccuracy: true or false, tried both
I have tried this plugin in versions 4.0.1, 2.4.3 and 2.1.0 and I almost always get timeout. Only if I run some other app, like GPS Status, and then wait for a long time, I can get a reading in my app. I'm not quite able to reproduce this success.
For certain reasons, I don't want to upgrade cordova-android, even though I have run out of options, so I might be forced to try that.
Definitely try that @Arxi, even if just to confirm if the problem goes away or not. Then you know what the reason is.
Okay, I'll try. In the meantime, I tried using the version 0.3.6 of this plugin, and I can confirm that works (all other variables staying the same).
For real? That version is from Feb 6, 2014...
Yeah, for real :) though I guess other problems would come up with that version (permissions and stuff), so I'm of course reluctant to use that.
Edit: Unfortunately, I'm simply not able to upgrade my cordova-android to v7, because the folder structure changed and my other cordova plugins and hooks don't work there. If there is any other way I can help, please let me know.
Edit2: okay, after creating a blank project with cordova-android 7.1.1 and cordova-plugin-geolocation 4.0.1, it works. After downgrading cordova-android to 6.4.0 in this blank project, it also works. So I guess there is some other problem in my original project - some interaction with other cordova plugins maybe? - which creates the problem.
Edit3: after bypassing ngCordova from my original project and using navigator.geolocation directly, it seem to work, or at least work most of the time. I need to test this further, but ngCordova seems to be the main culprit for me. Sorry if I hijacked this thread with an unrelated issue.
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.
So unsure what has changed in the Android patch, but here are my findings:
Tried with Samsung S7 with 8.0 Android, latest security patch and also Samsung S8 (8.0 Android), using v2.4.3 and as well as v4.0.1 of the plugin.
Samsung S7 works regardless no matter which version of the plugin. Samsung S8 stopped working suddenly regardless of which version of the plugin.
Passed in enableHighAccurancy: true, didn't help on Samsung S8.
Then, checked both devices settings, Connection > Locating Methods , both have already selected 'High accuracy'.
Then on Samsung S8, I selected 'Phone Only'. Still the plugin does not work for Samsung S8. So I reselected 'High accuracy'. Then as soon as I pressed 'Agree' on the 'Improve Location accuracy' prompt screen, the plugin works. It seems like there are some sort of permission changes in the latest patch...?!?!
Experiencing crashes in app on Oneplus6@Android 9 and AVD 8.1 Android simulation
Hello,
Same problem here, it's works fine on iOS and Android < 8.0.0. I use cordova-plugin-geolocation v2.4.3.
A patch is planned quickly for this bug ?
Thanks.
Any updates on this issue? I am facing the timeout issue in Android 8.1. Is there any workaround for this?