为什么我得到了带有Ionic Framework插件healthkit的错误plugin_not_installed? [英] Why am I getting the error plugin_not_installed with the Ionic Framework plugin healthkit?

查看:1588
本文介绍了为什么我得到了带有Ionic Framework插件healthkit的错误plugin_not_installed?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Ionic Framework一段时间,但我最近遇到了这个错误 plugin_not_installed 的Health Kit插件,我知道我基于我的 ionic cordova插件列表输出。

I have been using Ionic Framework for a while but I have recently come across this error plugin_not_installed for the Health Kit plugin which I know I have based on my ionic cordova plugin list output.

$ ionic cordova plugin list
> cordova plugin ls
com.telerik.plugins.healthkit 0.5.5 "HealthKit"
cordova-plugin-apprate 1.3.0 "AppRate"
cordova-plugin-badge 0.8.5 "Badge"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-dialogs 1.3.4 "Notification"
cordova-plugin-globalization 1.0.8 "Globalization"
cordova-plugin-google-analytics 1.8.3 "Google Universal Analytics Plugin"
cordova-plugin-inappbrowser 1.7.2 "InAppBrowser"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-local-notification 0.9.0-beta.1 "LocalNotification"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.3.0 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"

我的代码包含在 platform.ready()中,所以我知道所有内容都已加载。我还有我的健康包代码,它将错误抛在 healthKit.available() healthKit.requestAuthorization 没有错误。

My code is wrapped in platform.ready() so I know that everything is loaded. I also have my health kit code that is throwing the error in a healthKit.available() and a healthKit.requestAuthorization which have no error.

getWeight.then(function () {
    alert("Healthkit is ready!");
    alert(weight);
    healthKitReady = true;
 }).catch(function(err) {
     if (err) {
         console.log(err); // This is where the error is returned.
     }
  });

函数getWeight是这样的:

The function getWeight is this:

const getWeight = new Promise(function(resolve, reject) {
    var error;
    healthKit.readWeight({
        unit: "lb"
    }).then(function (out) {
        weight = Math.round(out.value);
        alert("weight: " + weight);
        resolve(weight);
    }, function (err) {
        error = err;
        reject(error);
    });
});

万一这是版本问题,这是离子信息的输出:

Just in case this is a version issue this is the output for ionic info:

cli packages: (/usr/local/share/.config/yarn/global/node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 7.1.0 

local packages:

    @ionic/app-scripts : 3.1.4
    Cordova Platforms  : ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    ios-deploy : 1.9.2 
    ios-sim    : 6.1.2 
    Node       : v8.9.1
    npm        : 2.15.12 
    OS         : macOS High Sierra
    Xcode      : Xcode 9.2 Build version 9C40b 

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro


推荐答案

如果你来到这里并没有任何效果,不要担心,这不是你的错误。

If you came here and nothing worked, don't worry, it's not your fault.

根据官方文档,你可能已经执行了这两个命令来安装插件:

You probably have executed these two commands to install the plugin as per the official documentation:

$ ionic cordova plugin add <your plugin>
$ npm install --save @ionic-native/<your plugin>

您还在 app-module.ts中添加了该插件档案:

@NgModule({
    ...

    providers: [
        ...
        Your plugin
        ...
    ]
...
})

您已经调用了已经正确导入并注入调用类构造函数的插件。

You are already making calls to your plugin which has been correctly imported and injected into your calling class's constructor.

您甚至在等待deviceReady事件开始使用您的插件:

You are even waiting for the deviceReady event to start using your plugin:

this.platform.ready().then(() => {
    //Use plugin now
});

然后你仍然得到 plugin_not_installed 错误。可能发生的一件事是,尽管存在节点和配置文件的多MB集群,但最近在项目创建时添加了插件。当您添加插件时,它已下载了存储库中可用的最新版本(!!!),对于项目中安装的某些平台(android或ios),此插件需要的Cordova版本大于您现在拥有的版本。再次键入第一个命令:

And then you are still getting the plugin_not_installed error. One thing that could be happening is that, despite this multi-MB clusterfuck of node and configuration files, the plugin was added recently while the project was created some time ago. When you added the plugin it has downloaded the most recent version available in the repository (!!!) and for some of the platforms installed in your project (android or ios) this plugin needs a Cordova version greater than the one you have now. Type again the first command:

$ ionic cordova plugin add <your plugin>

仔细查看输出。它看起来好了但是如果你向上滚动你可能会发现一个错误,说你已下载的这个插件需要Cordova android(或ios)版本X而你有Cordova android(或ios)版本Y,Y< X.示例:

And look carefully at the output. It looks like it went OK but if you scroll up you might find an error saying that this plugin you have downloaded requires Cordova android (or ios) version X and you have Cordova android (or ios) version Y with Y < X. Example:

Fetching plugin "phonegap-plugin-push@~2.1.0" via npm
Installing "phonegap-plugin-push" at "2.1.0" for android
Plugin doesn't support this project's cordova version. cordova: 7.0.2, failed version requirement: >=7.1.0
Skipping 'phonegap-plugin-push' for android

更糟糕的是,该插件已被部分添加,它可能存在于根插件文件夹和 config.xml 中,并且列出在 cordova插件列表命令输出中,但它不存在于 platform_www \plugins 文件夹中。

What is worse, the plugin has been partially added and it might be present in the root plugin folder and the config.xml, and is listed in the cordova plugin list command output, but it is not present in the platform_www\plugins folder.

如果是这种情况,您需要更新违规平台。 cordova平台更新已被弃用,因此您现在需要这样做:

If this is the case you need to update the offending platform. And cordova platform update has been deprecated, so you now need to do this:

ionic cordova platform remove android
ionic cordova platform add android@X

其中X是插件需要或更大的版本,例如7.1.0。

Where X is the version the plugin needs or greater, for instance "7.1.0".

现在你需要再次正确安装插件:

Now you need to properly install the plugin again:

$ ionic cordova plugin add <your plugin>
$ npm install --save @ionic-native/<your plugin>

我们尚未完成。在Android中,您可能会在设备上运行时遇到此错误:

We are not done yet. In Android you might now get this error when running on device:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:CordovaLib]

更新平台后,一些新代码需要更高的新minSDK。对于离子,你需要在 config.xml 中更改它:

After updating the platform, some of the new code requires a higher new minSDK. For ionic, you need to change this in the config.xml:

<preference name="android-minSdkVersion" value="19" />

希望你现在好起来。科尔多瓦真的很依赖依赖管理。此外,文档的编写好像每个人都拥有最新的一切。

And hopefully you will be OK now. Cordova really sucks in dependency management. Also the documentation is written as if everybody had the latest everything.

这篇关于为什么我得到了带有Ionic Framework插件healthkit的错误plugin_not_installed?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆