我一直在使用离子框架一段时间,但我最近遇到了这个错误plugin_not_installed
的健康套件插件,我知道我有基于我的ionic cordova plugin list
输出。
$ 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"
我的代码被 Package 在platform.ready()
中,所以我知道所有的东西都被加载了。我还有我的健康工具包代码,它在没有错误的healthKit.available()
和healthKit.requestAuthorization
中引发了错误。
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如下所示:
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);
});
});
为防止出现版本问题,这是离子信息的输出:
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
6条答案
按热度按时间uurv41yg1#
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:
You have also added the plugin in the
app-module.ts
file:You are already making calls to your plugin which has been correctly imported and injected into your calling class's constructor.
You are even waiting for the deviceReady event to start using your plugin:
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: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:
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 thecordova plugin list
command output, but it is not present in theplatform_www\plugins
folder.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:Where X is the version the plugin needs or greater, for instance "7.1.0".
Now you need to properly install the plugin again:
We are not done yet. In Android you might now get this error when running on device:
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
: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.
aiazj4mn2#
Use
platform.ready()
function before using the object of the imported class:3hvapo4f3#
This is a puzzling problem because it is not detailed. According to my observation, it may be an incompatibility between the version of the android and the plugin. For my case, ionic had generated android@7.0.0 while the plugin in this case "phonegap-plugin-push" required version android@7.1.0. How to have this information? This information is displayed when you run the "ionic cordova build android" command with the error messages that appear. So I went around the problem by following these steps:
ionic cordova platform rm android
manually remove config.xml
ionic integrations enable cordova --add
to generate a new config.xmlreinstall them all
ionic cordova platform add android@<version-android>
if the version is required by the plugin.However, it may be necessary to reinstall all the puglins to make sure everything is in order. How to reinstall a plugin properly?
REINSTALL A PLUGIN 2 STEPS
Uninstalling two commands:
ionic cordova plugin rm <plugin name>
npm uninstall --save <npm-of-plugin>
installing two commands:
ionic cordova plugin add <plugin name>
npm install --save <npm-of-plugin>
I hope this approach will help you to continue your projects properly. In any case, it worked for me.
IMPORTANT TO KNOW
For my previous intervention, I think it describes the solution to reinitianilize the ionic application by verifying that all plugins are installed. Because my application had bugs on a real device, no request to the API was working, and it was linked to a plugin that did not get well installed in this case the plugin "Document-viewer". While the error on the console of "DevApp" was related to the plugin "push-notification" and not the plugin "Document-viewer". And yet between these two plugins it was the plugin "Document-viewer" which was not installed well and the plugin "push-notification" was installed without problem. The proof, when I do the reset of the application by reinstalling all the plugins, my requests to the API works perfectly without bugs on a real device including notifications that work while on "DevApp" I always have the error "plugin_not_installed" of the push.
In conclusion
, I think that trying to reinstall the plugin does not solve the problem in any case, because I think that it is the test applications that do not support all the plugins as was the case here with "DevApp".Solution
So try to launch your application on a real device if it's bugs, tell you that all the plugins are not well installed.sz81bmfz4#
我也遇到了这个问题。问题是插件的版本不匹配。解决办法是通过
shift
+delete
和package-lock.json
删除node_module/
。用npm i
重新安装节点模块,然后用ionic cordova platform remove android
删除平台,然后添加平台并安装所有需要的插件。trnvg8h35#
我对IBeacon插件也有同样的错误。试着用xcode构建你的应用程序,并安装在你的iPhone上。
我认为问题是cordova对于一些插件(如IBeacon)。当我用
ionic serve -c
运行项目,并在我的iPhone上用Ionic DevApp打开它时,cordova返回错误plugin_not_installed
。所以我尝试在xcode上使用命令
ionic cordova build ios --prod
构建应用程序,启动在/platform/ios
上生成的.xcworkspace文件,并将其安装在iPhone上。(记住在xcode中签署应用程序并更改捆绑包标识符)!有关https://ionicframework.com/docs/intro/deploying/的更多信息
p8ekf7hl6#
不得不删除并重新创建Android文件夹,现在它正如预期的那样工作。就这么简单。
我希望这对其他开发人员有用