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.
Related
I currently use Cordova CLI on Windows to build hybrid Android apps. I am in the process of moving my development mover to a headless Ubuntu server. Getting java, NVM, Node, Android SDK and Cordova CLI installed on Ubuntu has not been a problem. Having done so and created the customary Cordova hello world project,
cordova create hello com.example.hello HelloWorld
I proceeded to add the Android platform
cordova plaform add android
and then attempted to build
cordova build android
at which point I was told
Error: Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
Installing Gradle by following the instructions given here - I am NOT installing Android Studio and am working on a headless Ubuntu machine so automatic Gradle installation is not an option - is not a problem. However, it is not clear to me which version of Gradle I should install.
I do not want to break my current Cordova project so I am trying to replicate the current Windows/Cordova CLI setup as closely as I can
Node 8.9.2
Java 8
Gradle ???
Dipping inside the gradle-wrapper.properties file in my existing project I find
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
I have noted that when I compile the project at present there are some ominous warnings about features to be removed from future versions of Gradle that are shown. I could experiment with using gradle-2.10 but it is not entirely clearr to me that it would indeed be the right version. Hopefully, someone here will be able to point me in the right direction.
First, clean up the project
cordova clean android
Then, force the cordova to use the distribution url with the version you want, in this case: gradle-6.3
export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=https\\://services.gradle.org/distributions/gradle-6.3-all.zip
Then, build your application.
cordova build android --release
I'm using Ionic to build an application, and have built a plugin to linkup the html-side and java-side.
However, every time I make changes to the plugin, I need to ionic platform rm android, than ionic platform add android, hence to refresh the plugin in corresponding android project.
Is there any command or method to help me quickly to achieve such purpose?
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
I have an android application that i built on PhoneGap 2.7.I installed phonegap 3.5 using cmd and tried to upgrade an app as shown here
How do I upgrade Phonegap in my Phonegap app?
But when i do it using cmd it gives me the following error:
Unlike phonegap 3.5 the android application that I built in PhoneGap 2.7 does not have a platform folder.So what am I supposed to?and how can I verify if it is upgraded or not?
I had also seen these phonegap documentation
http://docs.phonegap.com/en/3.5.0/guide_platforms_android_upgrade.md.html#Upgrading%20Android
But It does not show how to directly upgrade from 2.7 to 3.5
I don't think phonegap platform update works for upgrading from something older than 3.x.
For phonegap/cordova cli to work it has to detect a project with the structure of 3.x projects.
To upgrade your project in 2.x you have to
install phonegap or cordova cli (which you seem to already have done, but if you don't plan on using phonegap build, I suggest you use
cordova instead of phonegap. if not please replace cordova by phonegap
in next steps)
open a cmd and cd to a folder in wich you will want to put your project
create the new project from the www folder you had in your old project:
cordova create nameforprojectfolder com.test.app Testapp --copy-from=pathtooldwwwfolder
change current dir to the newly created folder
add the android platform:
cordova platform add android
in cordova/phonegap 3.x no plugin is added by default so you will have to add all the plugins you use :
cordova plugin add uri.of.plugin
customize config.xml to your needs
build the android project (this will create files in the platforms/android folder)
cordova build android
You may need to customize AndroidManifest.xml in platforms/android/AndroidManifest.xml
Now you can use the CLI to work with your project.
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!!