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"
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.
}
});
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>
You have also added the plugin in the app-module.ts
file:
@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.
You are even waiting for the deviceReady event to start using your plugin:
this.platform.ready().then(() => {
//Use plugin now
});
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>
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
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.
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
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>
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]
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With