How to remove cordova-plugin-compat?

Viewed 11654

In the release notes of cordova-android 6.3.0 (https://cordova.apache.org/announcements/2017/09/27/android-release.html) it's written down that cordova-plugin-compat has to be removed

If I try

cordova plugin rm cordova-plugin-compat

I get following error

[ERROR] An error occurred while running cordova plugin remove cordova-plugin-compat --save (exit code 1):

Error: The plugin ‘cordova-plugin-compat’ is required by (cordova-plugin-calendar, cordova-plugin-camera, cordova-plugin-file, cordova-plugin-geolocation), skipping uninstallation. (try --force if trying to update)

If I then try to --force the remove, it works, the plugin is removed and I'm able to build my android app.

BUT, I just removed my iOS platform to add it again and I face now the error

cordova prepare ios Error: Cannot find plugin.xml for plugin "cordova-plugin-compat". Please try adding it again.

[ERROR] An error occurred while running cordova prepare ios (exit code 1).

Any idea what am I doing wrong? Should really cordova-plugin-compat be removed? Why my iOS platform is referencing it, I thought it was only for android?

I use cordova-android@6.3.0 and cordova-ios@4.5.1

P.S.: If I remove and add the iOS platform, the compat plugin is automatically added as reference in package.json and package-lock.json

UPDATE

The last plugin release (https://cordova.apache.org/news/2017/11/10/plugins-release.html) most probably solve this issue respectively it looks like that the problem was the reference to the cordova-plugin-compat plugin from other plugin. But,

I'm not yet able to totally test it and solve it because I'm using another plugin where compat is also referenced (https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin/issues/426).

I will keep this thread open till I could 100% confirm that this solve the referencing of compat.

FINAL UPDATE

The PR to remove the dependency from Calendar-PhoneGap-Plugin to ‘cordova-plugin-compat’ went thru, I was able to remove this last plugin without "force"

6 Answers

For me what fixed it was updating the Android SDK via Android Studio, then running:

cordova plugin rm cordova-plugin-compat --force
cordova platform rm android
cordova platform add android@6.3.0

Hope that helps someone!

The cordova-plugin-compat is for Android only so it should not cause errors for iOS. I suggest to try to clean your Cordova project.

Delete the following directories : plugins, platforms, node_modules. They will be recreated

Then execute :

cordova platform add android
cordova platform add ios
cordova prepare # usually made by commands above but juste in case
cordova compile

You probably have another plugin that is requiring the compat plugin. Check your plugins' package.json for this.

remove plugin compat older than version 1.2

$ cordova plugin rm cordova-plugin-compat --force

then add version 1.2

$ cordova plugin add cordova-plugin-compat@1.2

This worked handsomely well for me!

Related