Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update cordova (phonegap) plugin in my project?

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.

like image 848
Michal Avatar asked Mar 15 '14 18:03

Michal


People also ask

How do I update Cordova plugin in ionic?

Update Cordova CLI, cordova Then compare the returned version number to the output of npm info cordova version (You can also check manually for the newest available version on npm or GitHub). Run cordova -v again after the update to make sure the update worked and it now returns the current version.


1 Answers

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.

like image 83
Michal Avatar answered Sep 20 '22 15:09

Michal