I’m trying to use some native plugins, but I can’t quite test them.
// app.component.ts
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = 'LoginPage';
//pushOpts: PushOptions;
//pushObj: PushObject;
constructor(private translate: TranslateService, private push: Push, platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
});
}
}
When I run ionic cordova run android -l -c --device I get the followings:
[13:39:15] console.warn: Native: tried calling StatusBar.styleDefault, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
[13:39:15] console.warn: Native: tried calling SplashScreen.hide, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
And on the app:
Uncaught (in promise): cordova_not_available
What’s wrong? Specifying --device should make cordova available, right?
Have you tried it without passing any flags to it? It could be something to do with live reload. Just a thought, eliminate everything extra and just try to run it with ionic cordova run android. Does that work?
alright i can confirm as of this date, this happens to me as well, while my setup was fresh install. This is defo a bug which needs rather a quick fix. anyway, just run
ionic cordova plugin add cordova-plugin-statusbar
it should output something like this
> cordova plugin add cordova-plugin-statusbar --save
Installing "cordova-plugin-statusbar" for android
Android Studio project detected
Adding cordova-plugin-statusbar to package.json
Saved plugin info for "cordova-plugin-statusbar" to config.xml
and Volla! that’s it. you won’t receive cordova error anymore. You can test by connecting you phone and by running ionic cordova run android -l -c