Cordova plugin not updating


#1

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!


#2

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.


How do I customize a ngCordova plugin so that changes in the plugin source code are updated in app?
#3

This is my project structure:

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


#4

Are you running cordova prepare android?


#5

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)


#6

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


#7

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.


#8

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.


#9

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


#10

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.


#11

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.


#12

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:


#13

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.


#14

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


#15

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


#16

@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.


#17

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.


#18

did anyone get a solution am having the same problem


#19

Delete the android.json in platforms/android


#20

Thanks johndesr that worked for me