Skip to content

TypeError: androidLocation.getProvider is not a function #19

@LaKing

Description

@LaKing
System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onLocationChanged failed
System.err: TypeError: androidLocation.getProvider is not a function
System.err: 
System.err: StackTrace:
System.err: locationFromAndroidLocation(file: app/webpack:/Hangmaffia/node_modules/@nativescript-community/gps/gps.android.js:101:0)
System.err: 	at onLocationChanged(file: app/webpack:/Hangmaffia/node_modules/@nativescript-community/gps/gps.android.js:36:0)
System.err: 	at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: 	at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302)
System.err: 	at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188)
System.err: 	at com.tns.Runtime.callJSMethod(Runtime.java:1175)
System.err: 	at com.tns.Runtime.callJSMethod(Runtime.java:1153)
System.err: 	at com.tns.Runtime.callJSMethod(Runtime.java:1149)
System.err: 	at com.tns.gen.android.location.LocationListener.onLocationChanged(LocationListener.java:24)
System.err: 	at android.location.LocationManager$LocationListenerTransport$1.operate(LocationManager.java:3196)
System.err: 	at android.location.LocationManager$LocationListenerTransport$1.operate(LocationManager.java:3193)
System.err: 	at com.android.internal.listeners.ListenerExecutor.lambda$executeSafely$0(ListenerExecutor.java:127)
System.err: 	at com.android.internal.listeners.ListenerExecutor$$ExternalSyntheticLambda0.run(Unknown Source:8)
System.err: 	at android.os.Handler.handleCallback(Handler.java:938)
System.err: 	at android.os.Handler.dispatchMessage(Handler.java:99)
System.err: 	at android.os.Looper.loopOnce(Looper.java:226)
System.err: 	at android.os.Looper.loop(Looper.java:313)
System.err: 	at android.app.ActivityThread.main(ActivityThread.java:8582)
System.err: 	at java.lang.reflect.Method.invoke(Native Method)
System.err: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:563)
System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)
System.err: java.lang.reflect.InvocationTargetException
System.err: 	at java.lang.reflect.Method.invoke(Native Method)
System.err: 	at com.tns.NativeScriptUncaughtExceptionHandler.uncaughtException(NativeScriptUncaughtExceptionHandler.java:58)
System.err: 	at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1073)
System.err: 	at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
System.err: 	at java.lang.Thread.dispatchUncaughtException(Thread.java:2200)
System.err: Caused by: java.lang.IllegalArgumentException: org.nativescript.Hangmaffia: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
System.err: Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
System.err: 	at android.app.PendingIntent.checkFlags(PendingIntent.java:382)
System.err: 	at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:465)
System.err: 	at android.app.PendingIntent.getActivity(PendingIntent.java:451)
System.err: 	at android.app.PendingIntent.getActivity(PendingIntent.java:415)
System.err: 	at com.tns.ErrorReport.startPendingErrorActivity(ErrorReport.java:157)
System.err: 	at com.tns.ErrorReport.startActivity(ErrorReport.java:136)
System.err: 	... 5 more

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:

  • CLI: Nativescript 8.1.4
  • Cross-platform modules: 8.1.5
{
  "name": "Hangmaffia",
  "main": "app/app.js",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "@nativescript-community/ble": "^3.0.29",
    "@nativescript-community/gps": "^3.1.0",
    "@nativescript/background-http": "^5.0.2",
    "@nativescript/camera": "^5.0.9",
    "@nativescript/core": "~8.1.1",
    "@nativescript/theme": "~3.0.1",
    "nativescript-audio": "^6.2.6",
    "nativescript-barcodescanner": "^4.0.1",
    "nativescript-nfc": "^5.0.0",
    "nativescript-vibrate": "^4.0.1",
    "nativescript-vue": "~2.9.0",
    "vuex": "^3.6.2"
  },
  "devDependencies": {
    "@nativescript/android": "8.1.1",
    "@nativescript/ios": "8.1.0",
    "@nativescript/webpack": "~5.0.0",
    "nativescript-dev-typescript": "^0.10.0",
    "nativescript-vue-template-compiler": "~2.9.0"
  }
}

Code

const gps = new GPS();

        gps.debug = true;
        const auth = await gps.isAuthorized();
        
        let location = await gps.getCurrentLocation({
            timeout: 2000,
        });

The app is crashing here.

If using skipPermissionCheck: true then the app doesn't crash, but there are no gps coordinates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions