How to update the already added Cordova plugin - android

I'm the development of cordova plugin in android.
Updating the javascript of Cordova plugin are not updated.
change:"./test/plugins/cordova-plugin-whitelist/whitelist.js"
cordova build android
Expect the update:/test/platforms/android/assets/www/plugins/cordova-plugin-whitelist/whitelist.js
In the version up of cordova it seems behavior has changed.
5.3.3-: OK
5.4.1+: NG
Thank you,

Instead of updating the plugin, I've found that I can remove it and re-add it. In my case, I'm referencing the plugin source code locally, via the --link option:
cordova plugin rm plugin-name
cordova plugin add custom-plugins/plugin-name --link
To make sure the correct version number is reflected in the newly added plugin, you can use:
cordova plugin ls

Run The below command
cordova plugin update plugin-name

Related

How to test cordova plugin while developing?

Can someone suggest a better way to test cordova plugin while developing it.
Right now the plugin is not pushed to github nor npm.
I am adding the plugin to my cordova android project using this command.
cordova plugin add cordova-test-plugin
But if I make any modifications to the plugin in the plugins/ folder, those changes are not reflecting.
How can I test the plugin while making changes.

Install Cordova plugin without package.json file on it

I'm trying to install a Cordova Plugin with Cordova CLI 7.
This plugin does not have a package.json file on it, so it throws an error when adding it to my project.
I've tried converting the config.xml file using plugman. And it works fine for Android but it doesn't for iOS. I feel like I'm missing some configuration from the config.xml in my package.json file.
Is there a way to safely convert the config.xml in a package.json file? or a way to install it using the config.xml file?
Thanks
Yes, since Cordova 7, the installation of platforms and plugins are by default performed using cordova-fetch which in turn uses npm install to add/remove modules. Therefore a package.json is required by default. But you should be able to add plugins lacking a package.json file by using the nofetch parameter, which forces Cordova to use the old method instead, please note that this parameter has been removed in cordova 8.0.0:
cordova plugin add cordova-plugin-camera --nofetch
For me when adding a custom plugin like so
cordova plugin add .\custom-plugins\my-plugin --nofetch
This does not work on MAC for me for some reason.
I resort to building it all for Android then copy over all the files, except node_modules and platforms, then do a 'cordova build ios' it seems to build fine with the custom plugins included. Not the best way i know, but once the plugin is added i can move on and continue. If you get it to work please share.
--nofetch option is removed in Cordova 8.0.0: https://issues.apache.org/jira/browse/CB-13055
If you have already installed Cordova 8.x.x then you can downgrade it to version 7.1.0 and then use the --nofetch option.
Run the following command to downgrade Cordova to 7.1.0:
npm install -g cordova#7.1.0
If the above command doesn't work, then try uninstalling cordova at first and then install cordova version 7.1.0:
npm uninstall -g cordova
npm install -g cordova#7.1.0
Then, check the Cordova version:
cordova --version

Ionic state reset not working

I had an older Ionic app, it was built a little bit ago, and I wanted to update some of it and reset the state. I updated the Ionic CLI and Cordova, and then I also did a state reset by doing: sudo ionic state reset
Every time I do this I receive this I receive the same error when it tries to update the Ionic keyboard plugin. This error never shows up if I do a state reset before updating the CLI, but it only shows up after. Tried manually adding and removing the plugin but it doesn't show up when using cordova plugins list Any help would be nice. Here's the error:
Removed platforms and plugins
Attempting to restore your Ionic application from package.json
Restoring Platforms
cordova platform add browser
cordova platform add ios
Restore platforms is complete
Restoring Plugins
cordova plugin add cordova-plugin-device
cordova plugin add cordova-plugin-console
cordova plugin add cordova-plugin-splashscreen
cordova plugin add com.ionic.keyboard
/usr/local/lib/node_modules/ionic/node_modules/ionic-app-lib/lib/state.js:543
throw 'Error executing "' + pluginCommand + '":\n' + output;
^
Error executing "cordova plugin add com.ionic.keyboard":
Fetching plugin "com.ionic.keyboard" via npm
Error: Failed to fetch plugin com.ionic.keyboard via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: Registry returned 404 for GET on https://registry.npmjs.org/com.ionic.keyboard
If you target Cordova 6, make sure that this plugin is supported by the targeted CLI version.
Starting from Cordova 6, VS will only allow or show you plugins that are supported by the targeted CLI version.
Hope this helps.
It has been updated from com.ionic.keyboard to ionic-plugin-keyboard, just update it in you package.json file.
I ended up having the same problem.
I'm running on windows and updated to cordova 6.0.0 and ionic 1.7.14
I got the error initially but then ran Node.js as Administrator and then the commands worked, see screen examples;
Like most things this solution may not be for everyone but I guess no doubt I wont be alone with this issue.
Cheers
state has been removed from CLI v3. So on cordova 7 you need to run:
ionic cordova prepare

Enable Multidex for Android in Ionic framework

Is there a way to set enable multidex (https://github.com/casidiablo/multidex) for Android if I build apps using Ionic Framework ?
There is a plugin that enables multidex. To install it, run:
cordova plugin add --save https://github.com/jwall149/cordova-multidex
And try building again. The build may take a little longer than usual, but your app should compile without troubles.
For those still having this issue, I've fixed it by installing cordova-plugin-multidex
cordova plugin add cordova-plugin-enable-multidex
Check it out: Multidex for Cordova
For people using androidx and cordova-android: 8 is interested in this solution, I created a fork that supports the file structure and class names of these new versions. Also works with Ionic.
cordova plugin add --save https://github.com/c00/cordova-multidex
Note that this is only relevant if you are still supporting a minSdk less than 21. At 21, multidexing is no longer needed as there is some built-in fix for it. So in that case, just remove the multidex plugin (if you had it) and things should work.
Try this
cordova plugin add --save https://github.com/jwall149/cordova-multidex
To fix this —
Install couple of androidx plugins to solve the issue. So simply run the following commands in your project root:
Add plugin to enable AndroidX in the project
1. ionic cordova plugin add cordova-plugin-androidx
2. Add plugin to patch existing plugin source that uses the Android Support Library to use AndroidX
ionic cordova plugin add cordova-plugin-androidx-adapter
3. Now run the following commands in your project root:
cordova clean
ionic cordova build android
https://medium.com/#AnkitMaheshwariIn/ionic-android-error-while-merging-dex-archives-unable-to-merge-dex-in-ionic-3f6272899aab

Phonegap geolocation plugin is not adding for android

Geolocation
I am trying to get geolocation details , i have added geolocation plugin using cordova command line
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git
$ cordova plugin rm org.apache.cordova.core.geolocation
Application created using cordova commandline
The Command-Line Interface
After adding plugin through command line android plugin is missing
in the following screenshot android is missing
Can anybody please help me ?
The native code for Android Geolocation was removed, see the deprecation bug. This was because the native implementation was buggy and the native browser geolocation works fine. Since Cordova (Phonegap)'s goal is to not exist, it was only a matter of time until this was removed. You can use Geolocation just like you normally would, it just won't use the native code and instead rely on the browser version.
If you look in the plugin xml file, you will see that there is still some lines in there about Android. This is so that cordova plugin add org.apache.cordova.geolocation will correctly copy in the needed permissions to run on Android.
Check this link : Go to Add Plugin Features
Add Plugin Features
You can use the CLI to search for plugins from this registry.
For example, searching for geolocation produces a single result that matches terms as case-insensitive :
Just search for plugin in command prompt.
cordova plugin search geolocation
By firing above command you will get search result as :
org.apache.cordova.geolocation - Cordova Geolocation Plugin
Now to install this plugin you need to fire :
cordova plugin add org.apache.cordova.geolocation
You will get result as :
Fetching plugin "org.apache.cordova.geolocation" via plugin registry
Installing "org.apache.cordova.geolocation" for android
Finally, the geolocation plugin will be installed in your application_name/plugins directory.
Path will look as : D:\PhoneGap\hello\plugins\org.apache.cordova.geolocation
Here are the steps to make you happy.It took a whole day for me to sort out this.
Better you downgrade the version of geolocation plugin. Go through below steps:
a)Remove the already downloaded geolocation plugin:
phonegap plugin rm org.apache.cordova.geolocation
b)Add the downgraded geolocation plugin:
phonegap plugin add org.apache.cordova.geolocation#0.3.2
Now you will see the android folder under the plugins folder.
Cheer up!!

Categories

Resources