-
-
Notifications
You must be signed in to change notification settings - Fork 76
getCurrentLocation gets timeout on Android API17 #42
Comments
Hi @dxshindeo Unfortunately I cannot find a device with API 17. I've tested it on API 18 and everything works as expected. Could you elaborate a little bit more info about this device? Do other apps (involving location services) work properly? |
I have this issue on Android 6 API 23. First I thought it's a Genymotion issue but I installed it on my Honor 6 where I'm getting a timeout when hitting the button. Any idea? |
I couldn't get this to work, so I switched to using Google's FusedLocationAPI ( I have an idea though (but won't have time to test it). First stating 2 facts:
In both scenarious, I think there is some map data flush happening that kickstarts the whole shabang. If I remember correctly, there should be some google maps flush function available in its sdk, but I'll be able to check that when I have more free time on my hands. |
Well, I stand corrected (https://guides.codepath.com/android/Retrieving-Location-with-LocationServices-API):
Which means I got null, because no other app had gotten location data. And when I started Google Maps app, it simply requested its updates. Weird though, I don't want to initialize cycle for my locations data retrieval. I just want to get it once, which means i have to start the update cycle and upon first data retrieval, end it. |
Thanks a lot for sharing your ideas and experience. Good to know, that other people are facing the exact same issue. What do you think? Is it possible to fix this inside of the nativescript geolocation package? In my opinion this would be the best way because the two facts from above just sound like workarounds. |
I suggest you actually switch to Googles' FusedLocationApi. Even android itself suggests us to do that (https://developer.android.com/reference/android/location/package-summary.html):
|
I will give it a try, thanks! |
@bart @dxshindeo Same problem here, i'm stuck with development since app won't work on both Android 6 and 7. |
I have the same problem here. It still does not work. Any solutions? |
@bart I'm stuck since days, i'm thinking to switch to pure android or something like react-native. There is not a single information on the web on how to access the FusedLocationApi from nativescript. Nativescript should be production ready, but if these are the response time on blocking issues, it's clearly not suited for production. |
It is not easy, but doable. I've stepped into many pitfalls, but I got it working after much trial and error. When I get home today, I will share my code here on how to access FusedLocationApi (~8h). |
Sounds great and looking forward to your solution @dxshindeo ! Thanks |
I will presume that you have installed
Explanation:
I believe this should get the ball rolling. This certainly is 90% more what I had to go on when I started this >.> |
Thank you so much @dxshindeo for sharing this. It looks like it's only an android solution. The main idea behind nativescript is its cross platform compatibility. Do you have an idea for that? My main question here is: Why does the nativescript-geolocation plugin not work correctly on all devices? |
Yes, this code fragment is for android only. I haven't gotten around to make iOS version yet, which will happen only after few months. You are right about the main idea about nativescript. So why aren't the necessary functions which fuel FusedLocationAPI been extracted and wrapped in
If you read up, even devs can't figure it out yet. And I doubt they will have time to push this, since FusedLocationApi is much better than built in android LocationManager. |
is there any timeline on this issue yet? |
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 what is a proper way to run the demo from PR? When I switch to demo directory and execute |
@ivanblazevic, I suppose you miss 'npm run tsc' in the src folder before running the demo app. |
I'm running android 7.1.1 version, btw when I click on update button nothing happens... |
@ivanblazevic Is the update button click crashing on a real device? The plugin requires Google Play Services 11.4.0+. The update button is part of the Google Play Services SDK and should navigate you to the Play Store. If you use emulators, you could take a look at this thread. I was able to update my Play Services version using the Android Studio 3.0 emulators. The button is not working in emulators without Play Store. |
I couldn't find api 17 Android device so I tested on 5.0.2 Lenovo A6010 and Android 5.0 Lenovo Vibe X2. Both devices were receiving locations. |
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. |
@DimitarTachev problem was with emulator, I updated Google Play Services using latest 3.0 emulators but after the update I was getting:
Anyways, I'll create new project with this new version and let you know if I get any errors. |
My app works fine on Android API 22 and higher. Got my hands on phone with API 17. Made a fresh
tns create test --ng
project, with"nativescript-geolocation": "^0.0.17"
version. Every request that gets sent, gets timed out.The text was updated successfully, but these errors were encountered: