Cordova plugin not updating

I have a question concerning plugins. I am using Ionic and Cordova for my hybrid app. I am using a toast (text popup) plugin to provide some feedback. Everything works but I decided that I needed some customization so I edited some of the .java files. It seems that my edit has no impact, it’s really strange, the plugin also seems to keep working even when I comment out the execute function.

I am using the following ionic command to test the app on my smartphone: “ionic run android”. Is there a way to compile the plugin from within my editor (webstorm)?

Any idea why the plugin is not updating? Thanks in advance!

1 Like

Where are you editing the plugin? Are you doing it from the plugins file or platform folder?

If its from the platform folder, those change will be overwritten every time you run ionic build android or cordova prepare android. You should be doing this from the plugins folder.

This is my project structure:

I’ve only edited the BackgroundGpsPlugin.java file (contains the execute function), it seems to have no effect.

Are you running cordova prepare android?

I just tried your command and ran “ionic run android” afterwards but the code still seems to execute the “older” version (even when I comment out the content of my execute method)

When I remove my android platform and install it back it works (it seems the only place where it installs plugins)

ionic run android will run your android project as is, with getting any changes from your www and plugins folder.

Running cordova prepare android will transfer those changes.

I’m having the same problem. Nether “ionic run android” nor “cordova prepare android” transfers my java code from the plugin folder to the platforms/android folder.

Can you try to delete the android.json file in the plugins directory? This will force the build process to update everything, think of it as adding a --force command to the build process like you would for git and grunt

1 Like

Hello, I am having the same issue with modifying an iOS plugin. I tried all of the solutions mentioned above, including deleting “ios.json”. Actually, deleting the “ios.json” file seemed to break all of the plugins, as if they were all deleted from the “platforms” directory (not verified). The only working solution is calling “ionic platform remove ios” followed by “ionic platform add ios”. I am running the latest version of Cordova/Ionic.

Exact same problem on my side. Trying to modify the files in the plugins directory and they changes are not reflecting at build time. This seems to be an old topic - did anyone find a solution?

cordova prepare does not work as explained.

You shouldn’t be modifying anything in the plugins directory, it is actually best practice to have the plugins directory part of your gitignore and not have plugins committed to source.

If you need custom functionality from a specific plugin, fork the plugin into your github repo, make the changes, and use your forked plugin rather than the original plugin. :smile:

1 Like

hi,
@mhartington, i am using plugin in my app, i was trying to modify plugin in plugins folder, after commend “ionic build android”, the file under the platform/src/com/ seemed not changed.

You need to re-install the plugin after making changes to the plugin files. i.e. download the plugin and then make changes and then add to your project by following command:

cordova plugin add /path-to-your-modified-plugin

None of the solutions above are working for me has anyone had any sucess updating the plugins?

1 Like

@cooervo I’m having the same issue. What I’m doing now is removing the android platform and adding it back again each time I make a change. Annoying, but it’s the best I’ve found.

yeah thanks ionic build android or ionic run android -l -c are working the latter makes a build to install in android so yes rebuilding is the solution.

did anyone get a solution am having the same problem

Delete the android.json in platforms/android

5 Likes

Thanks johndesr that worked for me

1 Like