【问题标题】:Ionic: cordova-plugin-ionic plugin is not installed when ‘ionic plugin add’ says already installed离子:当“离子插件添加”说已经安装时,没有安装cordova-plugin-ionic插件
【发布时间】:2018-04-05 06:01:20
【问题描述】:

我见过其他类似的问题,但仍然感到困惑。当我使用ionic serve 运行我的应用程序时,我的控制台告诉我:

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

但是当我跑步时:

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

上面写着:

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

我感觉这与我的另一个问题有关,即 Ionic Pro 的 Deploy 服务没有按预期工作。

这是我的环境:

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

【问题讨论】:

  • 相关github issue。看来您需要与那里的开发人员核实

标签: cordova ionic-framework


【解决方案1】:

在您的 app.component.ts 文件中:

在平台准备好后声明 rootpage 值,如下所示。

export class MyApp {
rootPage:any;
constructor(platform: Platform, statusBar: StatusBar,splashScreen: SplashScreen) {
platform.ready().then(() => {
this.rootPage = HomePage;
statusBar.styleDefault();
splashScreen.hide();
    });
  }
}

【讨论】:

  • 确实有效。 Ionic 的原生 HTTP 模块也有类似的问题。即使我使用官方文档安装它,它也显示错误未安装。谢谢!
【解决方案2】:

我通过检查 cordova 修复了这个 ionic pro 错误

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);
}    }

并添加到平台准备就绪:

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' })
        });
      });
    });

我认为更好的选择是检查平台是否为cordova,然后将其添加到函数中。

【讨论】:

    猜你喜欢
    • 2018-03-02
    • 1970-01-01
    • 2018-02-23
    • 2019-05-14
    • 2018-10-09
    • 1970-01-01
    • 2019-08-28
    • 2019-01-15
    • 1970-01-01
    相关资源
    最近更新 更多