ionic-framework: [Ionic v4.0.0-beta.12] Cordova is not available
Bug Report
Ionic Info
Ionic:
ionic (Ionic CLI) : 4.2.1 (/usr/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.12
@angular-devkit/build-angular : 0.7.5
@angular-devkit/schematics : 0.7.5
@angular/cli : 6.1.5
@ionic/angular-toolkit : 1.0.0
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.0, (and 5 other plugins)
System:
Android SDK Tools : 26.1.1 (/home/enzo/Android/Sdk)
NodeJS : v8.11.4 (/usr/bin/node)
npm : 5.6.0
OS : Linux 4.15
Describe the Bug Cordova is not loaded on a fresh-installation.
Steps to Reproduce Steps to reproduce the behavior:
- Start a project:
ionic start ionic4-test --type=angular - Add Android as platform
- Add some
@ionic-nativeplugin (like google-maps) - Run
ionic cordova run android -land you will see warnings/errors since cordova is not available, for example:Native: tried calling StatusBar.styleDefault, but Cordova is not available. Make sure to include cordova.js or run in a device/simulatorNative: tried calling SplashScreen.hide, but Cordova is not available. Make sure to include cordova.js or run in a device/simulatorError: Uncaught (in promise): TypeError: Cannot read property 'BaseClass' of null TypeError: Cannot read property 'BaseClass' of null(error with@ionic-native/google-maps)
Related Code GitHub.
Expected Behavior Cordova has to be loaded in the app.
Additional Context
In ionic 3 we had a script with cordova.js. Now, in ionic4, I don’t see that and don’t know how it should be included. But even in an fresh-installation app, it doesn’t work.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 7
- Comments: 20 (3 by maintainers)
Had this problem recently, and can confirm it only occurs with live reload enabled.
Solution: downgrade @ionic/ng-toolkit to 1.0.8 as opposed to latest 1.1.0.
Side note: Ionic seems to be switching to a merged package of ng-toolkit & schematics-angular called “angular-toolkit” which also contains the same problem with live reload, thus fresh installs also contain this problem since defaults to new merged package. So for now with fresh installs, uninstall @ionic/angular-toolkit and install @ionic/ng-toolkit & @ionic/schematics-angular (also need to switch angular.json to version that uses the two packages as opposed to the new merged one).
Thanks for your response! Could you open a feature request for it? That would be great 😃
UPDATE: You shouldn’t use livereload because this can to be a problem
For me it looks like an issue in your cordova creating process. I am creating several apps with Ionic and Cordova and do not have this issue.
ionic start ionic4-test --type=angularionic cordova platform add androidionic cordova run androidKeep in mind that in angular.json the correct builder have to be added from ionic
I can confirm @JupiterSymphony workaround is working with fresh project.
ionic cordova run --debug -lionic serve -cstill doesn’t have Cordova working on deviceHi!, finally solved downgrading @ionic/ng-toolkit to 1.0.8
thanks for @JupiterSymphony
Regards!
Sorry, I’ve update the answer with package.json