Hey guys I had a hell of time figuring out what the best way to modify the native Android code for an exiting Cordova plugin was. Here’s a quick write up below.
- Fork the cordova plugin you want to modify.
- Clone it locally to your computer.
- Navigate to https://github.com/apache/cordova-android and download the repo.
- Extract downloaded cordova-android .zip previously downloaded.
- Locate framework folder and pull into new directory.
- Rename framework folder to project name of your choosing.
- Open newly renamed framework folder in Android Studio.
- In Android Studio create a new package with the name that matches the package name of the Android plugin files.
- Copy all .java files from locally cloned cordova plugin to newly created android studio package (Ctrl+c, Ctrl+v with package highlighted in Android Studio works best).
- You now have code completion for Android / java / plugin working
- Now in order to push updates to forked cloned repo, you have the following options
11a. Setup an auto file replace from Android Studio project package name folder -> android folder in cloned repo
11b. Manually copy files in Andriod Studio project you changed & paste them into android folder in cloned repo (mark as replace all).
The last bit step 11 could use some work, but overall I hope this helps someone!