Question

Anyone knows what is the proper way to update cordova plugin in my cordova/phonegap project? Some time ago I installed file plugin as:

cordova plugin add org.apache.cordova.file

Everything worked fine. Now I realized there is a new version of the file plugin, so I wanted to update to get the new functionality. However, I haven't found a decent way to update. Actually, I can't update at all.

When I run remove command as:

cordova plugin rm org.apache.cordova.file

I get the following message:

Deleting plugin org.apache.cordova.file
No dangling plugins to remove.

What is interesting is that if I run

cordova plugin

right after, I still see org.apache.cordova.file in the list of installed plugins. Also, there is no single change on a file system. Nothing is removed, no file is updated.

Then I try to add a plugin again (as for updating the plugin is advised to remove it and add again) with:

cordova plugin add org.apache.cordova.file

Which outputs:

Fetching plugin "org.apache.cordova.file" via plugin registry
Plugin "org.apache.cordova.file" already installed on android.
Plugin "org.apache.cordova.file" already installed on ios.

And, even though this brings new version of java and javascript files (and some others), as I would expect, it brings them to myproject/plugins folder only.

It doesn't update files in platform folders (myproject/platforms/android/assets/www/plugins and myproject/platforms/ios/www/plugins) where it installed the files I installed them the first time.

Thus my project still keeps using the old version of the plugin.

So I wonder, how to update plugins. Any idea? Do I have to copy them manually to platform folders? Is this documented anywhere?

Thanks in advance.

Was it helpful?

Solution

So eventually I found the issue.

It seems, that there is a some sort of dependency between org.apache.cordova.file and org.apache.cordova.file-transfer. So if file-transfer plugin is installed, file plugin will not be removed, hence not updated if platform folders.

The solution is to remove file-transfer plugin first and then remove file plugin. Then adding file and file-transfer plugins will update those plugins in all platforms correctly, as one would expect.

Took some time to figure out, but does the trick.

OTHER TIPS

A bit late to the party, but I've added an option to my cordova-check-plugins tool that may be useful in this case:

--force-update

Forces the update of dependent plugins. By default, Cordova/Phonegap will not allow the removal of plugins on which other plugins are dependent, and therefore will not allow them to be updated. For example, cordova-plugin-file-transfer depends on cordova-plugin-file. By setting this option, both plugins will be updated (if updates are available). Without it, only the "parent" plugin - in this case cordova-plugin-file-transfer - will be updated.

So if you install the tool globally:

$ npm install -g cordova-check-plugins

Then run from the root of your Cordova project, you can force the update of plugins which Cordova will not allow to be removed (e.g. cordova-plugin-file) due to other plugins being dependent on them (e.g. cordova-plugin-file-transfer):

$ cordova-check-plugins --update=auto --force-update
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top