nativescript-geolocation icon indicating copy to clipboard operation
nativescript-geolocation copied to clipboard

TypeError: Cannot read property 'Accuracy' of undefined.

Open nicolaric opened this issue 3 years ago • 1 comments

Which platform(s) does your issue occur on?

  • Android Phone (Xiaomi) and Emulator

Please, provide the following version numbers that your issue occurs with:

  • CLI: 8.0.1
  • Cross-platform modules: 8.0.0
  • Runtime(s): N/A
  • Plugin(s): "dependencies": { "@angular/animations": "~11.2.6", "@angular/common": "~11.2.6", "@angular/compiler": "~11.2.6", "@angular/core": "~11.2.6", "@angular/forms": "~11.2.6", "@angular/platform-browser": "~11.2.6", "@angular/platform-browser-dynamic": "~11.2.6", "@angular/router": "~11.2.6", "@datorama/akita": "^6.1.3", "@nativescript-community/ui-mapbox": "^6.2.8", "@nativescript-community/ui-material-bottom-navigation": "^5.2.18", "@nativescript-community/ui-material-bottomnavigationbar": "^5.2.18", "@nativescript-community/ui-material-tabs": "^5.2.14", "@nativescript/angular": "^11.2.0", "@nativescript/background-http": "^5.0.2", "@nativescript/camera": "5.0.2", "@nativescript/core": "8.0.0", "@nativescript/geolocation": "^7.1.1", "@nativescript/imagepicker": "1.0.0", "@nativescript/theme": "~2.5.0", "@ngneat/transloco": "^2.21.0", "@ory/kratos-client": "^0.6.0-alpha.17", "@schematics/angular": "^9.1.0", "feather-icons": "^4.28.0", "nativescript-advanced-webview": "^6.1.1", "nativescript-carousel": "^7.0.1", "nativescript-http-formdata": "^3.0.1", "nativescript-permissions": "^1.3.11", "nativescript-social-share": "^1.6.0", "reflect-metadata": "~0.1.12", "rxjs": "~6.6.6", "tslib": "^2.1.0", "zone.js": "~0.11.4" }, "devDependencies": { "@angular-devkit/build-angular": "~0.1102.5", "@angular-eslint/eslint-plugin": "^0.5.0-beta.4", "@angular/cli": "^11.2.5", "@angular/compiler-cli": "~11.2.6", "@nativescript/android": "8.0.0", "@nativescript/schematics": "^11.0.0", "@nativescript/tslint-rules": "~0.0.5", "@nativescript/webpack": "4.1.0", "@types/jasmine": "~3.6.7", "@types/node": "^14.14.35", "@typescript-eslint/eslint-plugin": "^4.25.0", "@typescript-eslint/parser": "^4.25.0", "codelyzer": "^6.0.1", "eslint": "^7.27.0", "eslint-config-airbnb-angular": "^1.0.0", "eslint-config-airbnb-base": "^14.2.1", "eslint-config-airbnb-typescript": "^12.3.1", "eslint-plugin-import": "^2.23.3", "jasmine-core": "~3.7.1", "jasmine-spec-reporter": "~6.0.0", "karma": "~6.2.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage": "~2.0.3", "karma-jasmine": "~4.0.1", "karma-jasmine-html-reporter": "^1.5.4", "prettier": "^1.19.1", "prettier-eslint": "^11.0.0", "protractor": "~7.0.0", "ts-node": "~9.1.1", "tslint": "~6.1.0", "typescript": "^4.1.5" },

Please, tell us how to recreate the issue in as much detail as possible.

Hey guys, calling await geolocation.enableLocationRequest(); throws following error: Error: Cannot enable the location service. TypeError: Cannot read property 'Accuracy' of undefined. I tried several things, including the part on nativescript doc (https://docs.nativescript.org/plugins/geolocation.html#known-issues) , which tells you to add googlePlayServicesVersion = "16.+" to the before-plugins.gradle file. In the end, I dived into the code of the package. I found out, that the Enums import somehow isn't defined.(it also is deprecated, but has nothing to do with that). The Accuracy attribute is not even available in the namespace. I tried it on several PC's and always got the same error (could it be, that I use @nativescript-community/ui-mapbox as well, which uses the users location?). Thanks a lot for helping!

Is there any code involved?

`import * as geolocation from '@nativescript/geolocation'; ... ngOnInit() { await geolocation.enableLocationRequest(); // console.log(await geolocation.isEnabled());

const location = await geolocation.getCurrentLocation({
  desiredAccuracy: CoreTypes.Accuracy.high,
  maximumAge: 5000,
  timeout: 20000,
});

}`

nicolaric avatar Jun 04 '21 11:06 nicolaric

try yo update core version to the latest one "@nativescript/core": "8.1.3",

OPADA-Eng avatar Oct 02 '21 09:10 OPADA-Eng