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.
This worked for me!!
Use platform.ready() function before using the object of the imported class.
constructor(public qrScanner: QRScanner) {
// solve the problem - "plugin not installed".
platform.ready().then(()=>{
this.qrscanner();
})
}
Hope this helps...
I have the same error with IBeacon plugins.
Try to build your app with xcode and install it on your iPhone.
I think the problem is cordova for some plugins (like IBeacon). When i run the project with ionic serve -c
and open it on my iPhone with the Ionic DevApp, cordova return me an error plugin_not_installed
.
So i tried to build the app on xcode with the command ionic cordova build ios --prod
, launch the .xcworkspace file generated on /platform/ios
and install it on iPhone. (Remember to sign the app in xcode and change the Bundle Identifier)
!
More information on https://ionicframework.com/docs/intro/deploying/
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:
- run
ionic cordova platform rm android
- do
manually remove config.xml
- run
ionic integrations enable cordova --add
to generate a new config.xml
- do (if the plugins are not a lot,)
reinstall them all
- run
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.