danielsogl / awesome-cordova-plugins

Native features for mobile apps built with Cordova/PhoneGap and open web technologies. Complete with TypeScript support.
https://danielsogl.gitbook.io/awesome-cordova-plugins/
Other
2.4k stars 2.42k forks source link

Importing the "Geolocation" module causes app to break #2632

Closed Zerokk closed 6 years ago

Zerokk commented 6 years ago

I'm submitting a ... (check one with "x") [ x ] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/

Current behavior: When I try to import the Geolocation module in Ionic 4, the app totally breaks and throws the following error:

https://i.gyazo.com/68f0fcf217c4a4d9287387e74935d7f8.png

"Object(...) is not a function"

I've been trying to make various fixes that seemed to be around the web, like installing the 6th version of rxjs and rxjs-compat, but nothing seems to have any effect. Actually, I don't even need to use the module anywhere; the app breaks by just setting it up in the main module as a provider.

Expected behavior: Should be perfectly usable and not break the app... or at least, give a message developers can troubleshoot.

Steps to reproduce:

Other information: Ionic info: Ionic:

ionic (Ionic CLI) : 4.0.5 (C:\Users\zerok\AppData\Roaming\npm\node_modules\ionic) Ionic Framework : @ionic/angular 4.0.0-beta.1 @angular-devkit/core : 0.7.2 @angular-devkit/schematics : 0.7.2 @angular/cli : 6.1.2 @ionic/ng-toolkit : 1.0.5 @ionic/schematics-angular : 1.0.4

Cordova:

cordova (Cordova CLI) : 8.0.0 Cordova Platforms : none

System:

NodeJS : v8.9.0 (C:\Program Files\nodejs\node.exe) npm : 5.5.1 OS : Windows 10

Environment:

ANDROID_HOME : not set

package.json:

"name": "stepapp_client", "version": "0.0.1", "author": "Ionic Framework", "homepage": "http://ionicframework.com/", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/common": "~6.1.1", "@angular/core": "~6.1.1", "@angular/forms": "~6.1.1", "@angular/http": "~6.1.1", "@angular/platform-browser": "~6.1.1", "@angular/platform-browser-dynamic": "~6.1.1", "@angular/router": "~6.1.1", "@ionic-native/core": "^5.0.0-beta.14", "@ionic-native/geolocation": "^4.11.0", "@ionic-native/splash-screen": "5.0.0-beta.14", "@ionic-native/status-bar": "5.0.0-beta.14", "@ionic/angular": "^4.0.0-beta.0", "@ionic/ng-toolkit": "^1.0.0", "@ionic/schematics-angular": "^1.0.0", "cordova-plugin-geolocation": "^4.0.1", "core-js": "^2.5.3", "rxjs": "^6.0.0", "rxjs-compat": "^6.2.2", "zone.js": "^0.8.26" }, "devDependencies": { "@angular-devkit/architect": "~0.7.2", "@angular-devkit/build-angular": "~0.7.2", "@angular-devkit/core": "~0.7.2", "@angular-devkit/schematics": "~0.7.2", "@angular/cli": "~6.1.1", "@angular/compiler": "~6.1.1", "@angular/compiler-cli": "~6.1.1", "@angular/language-service": "~6.1.1", "@types/jasmine": "~2.8.6", "@types/jasminewd2": "~2.0.3", "@types/node": "^10.1.4", "codelyzer": "~4.4.2", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "~2.0.2", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.0", "karma-jasmine": "~1.1.1", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.4.0", "ts-node": "~7.0.0", "tslint": "~5.11.0", "typescript": "~2.7.2" }, "description": "An Ionic project", "cordova": { "plugins": { "cordova-plugin-geolocation": { "GEOLOCATION_USAGE_DESCRIPTION": "To locate you" } } } }

t8 commented 6 years ago

I am having the same issue

Tgure commented 6 years ago

@Zerokk Are you using ionic native version 5.0.0-beta.14 for geolocation? And in app.module when you import Geolocation does the import path end with /ngx like this import { Geolocation } from '@ionic-native/geolocation/ngx';?

danielsogl commented 6 years ago

You installed the wrong version. You have to install the beta release: npm install @ionic-native/geolocation@beta

MattiaSorella commented 11 months ago

I have the same issue and the npm install @ionic-native/geolocation@beta doesn't work eithe. And I don't know what to do