Ionic: Cordova plugin not updating

2019-08-30 10:40发布

问题:

I want to change the Barcode scanner plugin for Cordova a bit, so forked it and changed something rather simple for testing purposes.

As you can see on line 87, I changed the result_uri to result_text . This way, when I would scan a URL, the information would say I scanned plain text.

Then, I added this plugin to my Ionic project, using cordova plugin add https://github.com/binoculars88/phonegap-plugin-barcodescanner .

Browsing to the files in my text editors does show my edits. But... when I run the application on my device, it keeps saying "URL Found".

It's like my changes don't apply... Anyone knows what to do? Thanks a bunch!

UPDATE: I've tried changing the text itself in the strings.xml file, just for testing. I've noticed that this indeed needs a remove and re-add of the platform and plugin. After that, the text is changed.

So changes in strings.xml do apply, but the original problem remains: changes in a .java file don't seem to apply.

The ultimate goal of this testing, is to make the duration time after a code is scanned (and the result text is shown) smaller. In CaptureActivity.java, I've changed DEFAULT_INTENT_RESULT_DURATION_MS = 1500L to DEFAULT_INTENT_RESULT_DURATION_MS = 15L , but the duration time stays the same, even after removing and re-adding android platform and plugin.

回答1:

I have been doing work on the cordova-plugin-camera-preview and running these commands in succession seems to work:

ionic cordova platform rm android
ionic cordova platform add android
ionic cordova run android

I've set those commands as an alias so I can quickly recompile the .java files in the plugin.

I am still having issues though, I have added some functions to the plugin .java file but when I go to call those functions in my home.page.ts file, it says they don't exist.