Skip to content

[@nativescript/geolocation] - Error: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference #165

@jeanpaulattard

Description

@jeanpaulattard

The following exception is being thrown whenever I call the enableLocationRequest() method.

 Error: Uncaught (in promise): Error: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
JS: _systemDialogWillShow(file:///data/user/0/<directory>/files/app/vendor.js:145569:61)
JS:     at (file:///data/user/0/<directory>/files/app/vendor.js:145468:14)
JS:     at ZoneAwarePromise(file:///data/user/0/<directory>/files/app/vendor.js:146586:29)
JS:     at enableLocationRequest(file:///data/user/0/<directory>/files/app/vendor.js:145465:12)
JS:     at (file:///data/user/0/<directory>/files/app/bundle.js:441:79)
JS:     at ZoneDelegate.invoke(file:///data/user/0/<directory>/files/app/vendor.js:146072:26)
JS:     at onInvoke(file:///data/user/0/<directory>/files/app/vendor.js:73479:33)
JS:     at ZoneDelegate.invoke(file:///data/user/0/<directory>/files/app/vendor.js:146071:32)
JS:     at...

In the ngOnInit of my component, I'm calling the following piece of code

import { enableLocationRequest, isEnabled } from '@nativescript/geolocation';

...

isEnabled().then((enabled: boolean) => {
    if (!enabled) {
        return enableLocationRequest(true, true);
    }
});

This is happening on Android 11. Below are my gradle files and the permissions I have in the AndroidManifest.xml

android {
  defaultConfig {
    minSdkVersion 22
    generatedDensities = []
  }
  aaptOptions {
    additionalParameters "--no-version-vectors"
  }
}
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

Am I missing something? This is happening every time that method is called, and according to the docs that's all that is required to request location. Thanks in advance.

Package.json include the following versions

"@angular/animations": "~11.2.7",
    "@angular/cdk": "10.2.5",
    "@angular/common": "~11.2.7",
    "@angular/compiler": "~11.2.7",
    "@angular/core": "~11.2.7",
    "@angular/forms": "~11.2.7",
    "@angular/material": "10.2.5",
    "@angular/platform-browser": "~11.2.7",
    "@angular/platform-browser-dynamic": "~11.2.7",
    "@angular/router": "~11.2.7",
    "@nativescript/angular": "~11.8.0",
    "@nativescript/core": "~8.0.0",
    "@nativescript/geolocation": "7.2.1",
    "@nativescript/theme": "3.0.0",
    "nativescript-permissions": "1.3.11",
    "reflect-metadata": "0.1.13",
    "rxjs": "~6.6.7",
    "tslib": "2.0.3",
    "zone.js": "~0.11.1"

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