-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: androidLocation.getProvider is not a function #19
Comments
@LaKing i have fixed the issue in 3.1.1 however it means the native side reported a "null" location which should not happen. Maybe you are missing permissions |
Thank you @farfromrefug ... I added myself to your sponsors .) |
@LaKing wow thank you! Dont hesitate to find me on discord if you have issues with getting locations on android 12. |
@farfromrefug Thanks!! |
Reproducing in a minimal code
Edit AndroidManifest to add permissions
Edit AndroidManifest to add within the application block
Edit import Items from "./Items.vue";
import Browse from "./Browse.vue";
import Search from "./Search.vue";
import { GPS } from "@nativescript-community/gps";
export default {
components: {
Items,
Browse,
Search,
},
created() {
console.log("------------@ created--------------");
async function test() {
console.log("----------- @ test---------------");
const gps = new GPS();
gps.debug = true;
if (!gps.isEnabled()) {
console.log("---------- @ Location not enabled, requesting. -----------");
return gps
.authorize(true)
.then(() => gps.enable())
.then(() => gps.isEnabled());
}
const auth = await gps.isAuthorized();
console.log(" --------------- GPS getLocation: authorized", auth, "--------------");
const location = await gps.getCurrentLocation({
timeout: 2000,
//skipPermissionCheck: true
});
console.log("------------ @ location--------------", location);
}
test();
},
}; Eventually edit ```app.js``
With a physical android device connected run, ...
The application requests the GPS permissions.
|
I'm using the 3.1.1 version and the plugin is failing to return my location on android. It works fine on iOS. I'm using the latest alpha versions of cli, android, and core. I'm seeing this in my sdk 31 emulator and on my samsung phone - Android 12. I also ask for permissions when the app starts and allow when using the app. I am seeing the error listed above: I'm requesting the location as follows (I'm not setting skipPermissionCheck: true) but I don't know what the default is. |
@NachmanRoss you could contact @farfromrefug or other maintainers on discord, and debug the issue. The code for the minimal reproduction is above. .... Would be nice to get this plugin working, I'm using another GPS plugin for now. |
@NachmanRoss you need to debug this. in the error stack it tells you where the error happens. there add a |
@farfromrefug Since the problem can be reproduced in an empty project, it does not make sense to ask users of the plugin to debug this in their projects. The plugin is broken in general, and not in a specific project. |
I agree with LaKing. I only have one place where I call the plugin to get the location and the code for that is shown above. I also for permission to use it in this one place: The error that I see in the log is when the android app is launched after being sent into background in this code from my app.ts file: So I never call the getProvider myself. It is being triggered when the app is brought into the foreground on android. It's probably happening during the getCurrentLocation call and is probably something that the android app is losing a pointer to when it is sent to the background. |
@LaKing @NachmanRoss i have that plugin working in production in around five apps. and me have sessions running in background for.more than 8 hours. about the issue i am helping blind here. did you add everyhting necessary in your manifest file ? |
I'm not unwilling to help but I don't know how to help. I've literally posted the only two places that I explicitly call the plugin. Both are localized to one class. One call to get authorization and the other call to getCurrentLocation. The trace log that is printed by the Application.on(Application.uncaughtErrorEvent doesn't mention my class or my use of getCurrentLocation. So I'm at a loss. I'm willing to install a debug version of the plugin with more error messages and try that but otherwise I'm not sure where to begin to look on my own. None of the statements listed in the trace log are from my classes or code. They're all from within the plugin and its internal calls. |
@farfromrefug can you please check if you can reproduce the issue with the minimal code for reproduction?
|
@NachmanRoss thanks for wanting to help. as i said in an earlier post, as i cant reproduce it here what i need is for you to reproduce the issue after adding a console log. if you have a callstack like mentioned in the firstpost then the callstack tells you where yhe error is happening (function/line/file). |
@NachmanRoss just saw you mentioned the new alpha of N. can you try to rollback ? does it work ? |
Here are my current versions: I might be able to rollback except that other functionalities that my app has require a gradle 7 build which is why I started using the alpha packages. I can attempt with the minimal code but I'm not familiar with vue. I can attempt to reproduce the minimal version but as a straight typescript project. Is that possible and would I replace app.vue with app.ts? |
@NachmanRoss are we talking abiut the runtime or the core ? please can you details what version it works with and which it does not ? |
My app doesn't work on android with the versions I listed above your last comment. The same app works perfectly in iOS with the above versions. I also attempted to create a minimal version using the ns create command. I created a typescript project using the Hello World template. I then added the AndroidManifest entries and the gps plugin. I also updated to the same @nativescript/core, @nativescript/android, @nativescript/ios, and @nativescript/webpack shown above. My ns -version reports: 8.1.5-next-12-23-2021-1617049163. The problem is that it builds without errors but when I try to run it using ns run android, I get the following error that I've never seen before although I've created and run many apps over the years: webpack 5.68.0 compiled successfully in 185 ms I have no clue as to why the app won't run on the emulator. It shows as an installed app on the emulator but even if I tap on it and try to start it manually it crashes. So I can't reproduce the error in order to send you the log trace. |
Ok. I was able to get the minimal typescript app running and it throws the following when I tap on the Tap Button in the main-view-model.ts which runs the getCurrentLocation function: |
I hope this helps and I can zip up the app (minus the node_modules, platforms, and anything else that will be generated by the build command) and send it to you if you want. |
@NachmanRoss You are running this on a 31 api level emulator?
Though this plugin does not use PendingItent :s EDIT: yes please share the app |
Here's the zip file. Its only 189 KB |
Yes. I'm running it on a 31 level emulator and on my android phone using Android 12. |
@NachmanRoss @LaKing it should be fixed in 3.1.2. It was due to some API changes in android 12. Sorry for the trouble |
I added the new version and did an ns clean. Yet in my emulator the location is still returning as null and on my phone it doesn't appear to be working either. I'll see if I can spot any errors later this morning as I have to take a break for the next hour. Thanks for the work that you're putting into this. |
@NachmanRoss weird i tried on a 31 emulator and it worked just fine. import { Application, Trace } from '@nativescript/core'
import { GPSTraceCategory } from '@nativescript-community/gps'
Trace.addCategories(GPSTraceCategory)
Trace.enable() and send me what you get when the null is returned |
Here's what I'm getting in my full blown app with the extra trace statements added to app.ts. JS: about to process request to get current location I'll also try this on the minimal version of the app that I sent you yesterday. |
@NachmanRoss ok you simply timeout with no location found! |
I ran it in the minimal app and I'm getting this trace which looks strange to me because it seems to be finding the emulator's location yet it says that the location is null. Here's the trace and the code that I'm running: Here's the code I'm running: Am I making the call incorrectly? And why doesn't my full blown app show the same message onLocationChanged that the minimal app shows? They both use the same call and are running on the same emulator. |
@NachmanRoss ok it is still normal "in a sense" the location is returned is seen as too old as it has an age of |
@NachmanRoss can you send me the log with |
Do you mean a plugin version of 3.1.3? I just tested with the 3.1.2 version because that’s the version that you posted had the fix. ***@***.******@***.*** it should be fixed in 3.1.2. It was due to some API changes in android 12. Sorry for the trouble"
I didn’t check if there was a 3.1.3 version. Let me try with the 3.1.3 version. Also what I sent you was in effect the only log that I am seeing in the console. Do you want me to add some other log statements? Let me know and I’ll try whatever you suggest. Meanwhile I’ll try with the 3.1.3 version ad if it doesn’t work, I’ll increase the timeout and see if that helps.
Nachman Beinish Ross
On Feb 14, 2022, 9:20 AM -0500, farfromrefuge ***@***.***>, wrote:
@NachmanRoss can you send me the log with 3.1.3 ?
—
Reply to this email directly, view it on GitHub <#19 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AKUWSSYL2HTHUSGWJV7LC5TU3EE67ANCNFSM5JQ7ZNYA> .
You are receiving this because you were mentioned. <https://github.com/notifications/beacon/AKUWSS4TBYHQ4AMFKQ65USLU3EE67A5CNFSM5JQ7ZNYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHXX7HXQ.gif> Message ID: ***@***.***>
|
@NachmanRoss just the same exact test for you with 3.1.3. There will be more logs |
I tried with the 3.1.3 version and added the time when the call returns after the timeout period. It worked once and failed twice yet it's the same call being invoked when the user taps on a button.: JS: about to call getCurrentLocation() JS: about to call getCurrentLocation() JS: about to call getCurrentLocation() |
@NachmanRoss i think the time in your emulator is set to 3 days old. Not a big deal but so you know ;) |
I feel like a real idiot for not noticing that. I installed the minimal app on my phone and it works most of the time. Then I tried it in my full blown app and noticed that it also works intermittently. So I added your trace statements and attached my phone to my mac and tested on it. Here's the log showing how one call works and the other fails. Could it be that I'm triggering the calls too many times in a short period of time and they're interfering with each other? JS: N-GPS: enabled provider: passive I can try adding logic to skip the call if the time of the call is within a minute of an earlier call but maybe you have a better idea. |
@NachmanRoss no it is not normal it should return. could you try and reproduce in the sample app? |
This is my sample app where I tap the button to get the coordinates repeatedly. You can see the first call works and the others eventually return null. JS: about to call getCurrentLocation() |
I also updated my full blown app and installed the release .apk version so that it does the following check: If the current time is greater than the lastCheck + 60000, it gets the coordinates from the plugin and saves them. If the check is within the last minute, it returns the saved coordinates instead of asking the plugin to get them. With that change, the app initially didn't get the coordinates but it is working now. |
I spoke too soon. The full blown app is still failing to get the coordinates on a reliable basis. It is working sometimes but not every time. |
Which platform(s) does your issue occur on?
I see this corrently on the latest Android version, with a physical device.
Android 12
Please, provide the following version numbers that your issue occurs with:
Code
The app is crashing here.
If using
skipPermissionCheck: true
then the app doesn't crash, but there are no gps coordinates.The text was updated successfully, but these errors were encountered: