-
-
Notifications
You must be signed in to change notification settings - Fork 77
Timeout searching for location on Android (Nativescript 3.0.3) #62
Comments
same thing happening with me. any help ? |
I noticed that sometimes the internet connection type may cause this problem so try to change internet provider. |
Hi @clarenceh, looking at the sceenshots I see that you are running the app on emulator. You might check the Location options/settings/controls of the emulator if you can "Send" location to the device like the Android emulator for Mac: |
Got the same problem. I don't think it has anything to do with emulator tho 😕 |
I get the same error. iOS is working but Android unfortunately not. |
Has anybody found a solution for this issue on Android? I am still getting the following "JS: Error: Timeout while searching for location!" |
Running the Send location command as described in the Android emulator makes it work for me - of course that is a workaround and generally unpleasant. |
@tbozhikov Sorry for my late reply. Yes I can send location to the emulator. I opened Google Map, and then in emulator's location setting, change the value for latitude and longitude, and the location on the map was updated successfully. Have you had a chance to check out the NS Angular examples and test it out as I mentioned in my message? I believe you will be able to re-produce this. Many thanks, Clarence |
Got the same issue here. Tested on many emulators and many real devices. Using version 3.0 of the plugin As for my dependencies:
|
Hi , i have error same thing, i fix with open Location( or GPS ) of device choose Location Mode is a Hight accuracy. A reason is your device auto turn on Battery saving move or Device only mode. it is slow in get location from GPS. that plugin working with android and ios with me, i think it not a prolem. |
@LeCaoPhuc Regarding the different tests I've done this weekend: on a real device it works well when data is active. If gps + wifi are active then it's not working well - even if accuracy is set to the highest on device settings |
@jeremypele your mean is in real device, if you use data (3g,4g) and turn on gps then you always get location. but if use wifi to connect internet, location will slow and time out if accuracy not in highest . |
same thing happening with me. any help ? |
Same problem for me on real Galaxy S7 with Android 7. |
Hi have this problem on my Samsung A5 |
Hi guys, please try to set the "desiredAccuracy" option to "Accuracy.high" (see https://docs.nativescript.org/hardware/location#getcurrentlocation). |
I have tried it and nothing changed
…On Aug 19, 2017 1:16 PM, "Fabian F." ***@***.***> wrote:
Hi guys, please try to set the "desiredAccuracy" option to "Accuracy.high"
(see https://docs.nativescript.org/hardware/location#getcurrentlocation).
That solved the problem for me 👍
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#62 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACGJaNBxmjg5KFaN1oJcCpTIUryDUyQoks5sZrYWgaJpZM4Nw1CF>
.
|
nativescript-geolocation plugin version: 3.0.1 I had the same problem as described. Apparently first you have to call So here is what I did (I practically called function buttonGetLocationTap(args) {
if (!geolocation.isEnabled()) {
geolocation.enableLocationRequest();
}
watchId = geolocation.watchLocation();
var location = geolocation.getCurrentLocation({desiredAccuracy: 3, updateDistance: 5, timeout: 20000})
.then(function(loc) {
if (loc) {
console.log("Latitude " + loc.latitude);
console.log("Longitude " + loc.longitude);
console.log("Altitude " + loc.altitude);
console.log("Horizontal Accuracy " + loc.horizontalAccuracy);
console.log("Vertical Accuracy " + loc.verticalAccuracy);
console.log("Speed " + loc.speed);
console.log("Direction " + loc.direction);
console.log("Timestamp " + loc.timestamp);
geolocation.clearWatch(watchId);
}
}, function(e){
console.log("Error: " + e.message);
geolocation.clearWatch(watchId);
});
}
exports.buttonGetLocationTap = buttonGetLocationTap; Hope it helps. |
Per TinoN's suggestion, I added this before my call to getCurrentLocation and it works. Note, this is the typescript version: correction - this is not working reliably. The only thing that works reliably is clicking the send button in the emulator controls as per tbozhikov's suggestion above. |
@toeknee581 I checked it again with my phone. It worked in the office where I have WiFi. As soon as I left the building and had only access to mobile network it didn't work. On my mobile phone I switched the phone location settings from "High accuracy" to "Device only" to force GPS only usage. The data was then most of the time retrieved reliably (sometimes the phone GPS couldn't be accessed...). But when I came back to my office I switched back the phone settings to "High accuracy" to make sure that GPS, WiFi or Mobile can be used to determine location. From then on it stopped working in the office. So I agree with you, it is not working reliably and I also can't reproduce when it is working and when not... |
Nativescript version: 3.1.3 Hello, |
@TinoN1e unfortunately your code doesn't work on my phone Android 5.1 (I changed your permission function to fit my API level). to clarify more about this issue: actually everything works fine with nativescript-geolocation in emulator when "Send" button inside emulator pressed. but I tried the same code on real devices with different android versions but no result with COARSE or FINE, watch or single update... I traced nativescript-geolocation completely and nothing is wrong here. also I wrote an example app like @TinoN1e to work directly with android APIs but it doesn't work neither. so I think maybe something is wrong with nativescript code or android runtime. I didn't try Fused Location API on android. maybe this works rather than using location manager. I will try it tomorrow and share the results. |
I finally succeeded to get the GPS work I also noticed, that if you move a little bit in the offices, the location change event can be triggered, which will then give you the correct geolocation data. |
As there are a lot of issues with the Android Location Manager and it's not the recommended approach for getting a location on Android, we fully replaced the Android implementation with the Google Play Location Service one (used by Google Maps). The change is currently on a pull request and we are still testing some edge cases. However, you could check if your issues are resolved using the tachev/location-manager-to-google-play-services branch. |
@DimitarTachev I tried your branch and still I get timeout. |
today I tested the same app on iOS 11 and I get timeout there too. so the problem is not related to Android side. maybe a Nativescript runtime issue? |
@DimitarTachev @mohammadrafigh Using your branch and the corresponding demo on Lenovo A6010 Android 5.0.2 I was able to get location using gps service. |
@mohammadrafigh Regarding iOS, be sure you have wifi on. This seems to fix it on my side but I guess this should be a separate discussion for another issue related to iOS. |
We closed the issues as the Android implementation is fully replaced by a new one and we are not able to reproduce the timeouts anymore. You could take a look at the 4.0.0 release notes here. |
ah nice. I can now confirm that the issue is fixed on Android. I don't know why in previous try I got timeout. but now everything works fine. thanks @DimitarTachev . |
I'm also getting this. |
Bump. I get the same issue even in latest version 4.2.1 |
I am getting the same error with version 4.2.2. I also tried the watchLocation trick. |
Hi @guestisp, @scottmcmu,
This info will help us to recreate the issue and to verify if there is a real problem. |
@tsonevn i've opened a new issue |
I had the same issue and solved it by changing to |
I have the same problem |
I figured out that if you follow the tutorial it is actually incorrect. At least now it currently says to use:
However I realized that
if you want to use it that way. Or if you don't change your import statement you can use: |
I have this error, i add timeout 0 for resolve the problem |
@youtpout answer worked for me,
If you use anything else will throw an exception for timeout, putting timeout:0 works for another desiredAccuracy value,,, |
I try on real device |
I saw issues reported on forum and this repository about issues on reading location on Android on NS3.0. I just want to report that it also not working on Nativescript Sample application.
Steps to reproduce:
tns install
tns run android --emulator
The plugin runs fine on iOS.
Attached please found the screenshot for your reference.
Versions:
│ Component │ Current version │ Latest version │ Information │
│ nativescript │ 3.0.3 │ 3.0.3 │ Up to date │
│ tns-core-modules │ 3.0.1 │ 3.0.1 │ Up to date │
│ tns-android │ 3.0.1 │ 3.0.1 │ Up to date │
│ tns-ios │ 3.0.1 │ 3.0.1 │ Up to date │
Hope this can help and let me know if need any further information.
Regards

Clarence
The text was updated successfully, but these errors were encountered: