I\'ve been struggling to set up my cordova plugin project. Mainly due the facts that:
Plugins need to be in a separate folder away from the main project
I would like to suggest yet another workflow for the development of Cordova plugins. It approach is similar to the workflows already mentioned earlier, with the difference that I like to have an independent project to maintain + test + debug the plugin code without the need for a separate test application.
The outline of the workflow looks like this.
Step 1 - Prepare the Cordova platform.
1.1 Download android release cordova-android-x.y.z.zip of the version you want from the github source site:
https://github.com/apache/cordova-android
1.2. Expand the archive, go to framework/ directory
1.3. create a local.properties file with contents: 'sdk.dir=/opt/android-sdk'
Adjust the path so that it points to the location of the Android SDK on your machine.
1.4. Execute: 'ant jar'
The result is a cordova-x.y.z.jar
Step 2 - Create/test the plugin with IDE support.
2.1. Create an empty Android project using Android Studio.
2.2. Copy the cordova-x.x.x.jar to the app/libs directory of your project.
2.3. Create the plugin code + unit tests (you have code completion and can build the code using the unit tests).
2.4. OPTIONAL If necessary you can add a webview and test the code inside the webview as described here
https://cordova.apache.org/docs/en/latest/guide/platforms/android/webview.html
Step 3 - Package plugin files.
3.1. Create a plugin project with plugman.
3.2. Copy the files from the development project into the plugin project
3.3. Deploy and reuse.
The last step 3 could be automized, I personally never got around doing this.