Ionic: cordova-plugin-ionic plugin is not installe

2019-01-29 04:56发布

I have seen other similar questions but am still confused. When I run my app using ionic serve, my console tells me:

ionic-pro.min.js:1 the cordova-plugin-ionic plugin is not installed. Install it for better device information for runtime errors.

but when I run:

cordova plugin add cordova-plugin-ionic --variable APP_ID=app_id --variable CHANNEL_NAME=Production

it says:

Plugin "cordova-plugin-ionic" already installed on android.
Plugin "cordova-plugin-ionic" already installed on browser.
Plugin "cordova-plugin-ionic" already installed on ios.

I have a feeling this is connected to one of my other issues, which is Ionic Pro's Deploy service not working as expected.

Here's my environment:

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.14.0
    ionic (Ionic CLI) : 3.14.0

global packages:

    cordova (Cordova CLI) : 7.0.1 

local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : android 6.1.2 browser 4.1.0 ios 4.1.1
    Ionic Framework    : ionic-angular 3.0.1

System:

    ios-deploy : 1.9.1 
    ios-sim    : 5.0.13 
    Node       : v6.11.0
    npm        : 2.15.12 
    OS         : macOS Sierra
    Xcode      : Xcode 9.0.1 Build version 9A1004 

Misc:

    backend : pro

2条回答
冷血范
2楼-- · 2019-01-29 04:57

I fixed this ionic pro error by checking cordova

handleError(err: any): void {
    if (this.platform.is('cordova')) {
  // This will only print when on iOS
  console.log('I am an iOS device!');
  Pro.monitoring.handleNewError(err);
  // Remove this if you want to disable Ionic's auto exception handling
  // in development mode.
  this.ionicErrorHandler && this.ionicErrorHandler.handleError(err);
}    }

And add to platform ready:

this.platform.ready().then(() => {
      /** Pro handlings */
      Pro.init('7dafc58e', {
        appVersion: '0.0.1'
      })
      try {

        this.ionicErrorHandler = injector.get(IonicErrorHandler);

      } catch (e) {
        // Unable to get the IonicErrorHandler provider, ensure
        // IonicErrorHandler has been added to the providers list below
      }
      this.AppCenterCrashes.setEnabled(true).then(() => {
        this.AppCenterCrashes.lastSessionCrashReport().then(report => {
          Pro.monitoring.log(JSON.stringify({ report: report }), { level: 'error' })
        });
      });
    });

I think better option would be to check if platform is cordova and then add it to the function.

查看更多
贼婆χ
3楼-- · 2019-01-29 04:59

In your app.component.ts file :

declare rootpage value after platform ready like below.

export class MyApp {
rootPage:any;
constructor(platform: Platform, statusBar: StatusBar,splashScreen: SplashScreen) {
platform.ready().then(() => {
this.rootPage = HomePage;
statusBar.styleDefault();
splashScreen.hide();
    });
  }
}
查看更多
登录 后发表回答