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
The solution I tend to use follows that outlined by Niko in the accepted answer. However, I add the --link flag when adding the plugin:
cordova plugin add --link ../cordova-plugin-example
which (at least on Mac and probably Linux) creates symbolic links to the plugin directory instead of copying it. Then, editing the plugin files within the Android project in 'platforms/android' with Android Studio actually modifies the files in the plugin directory. This allows to keep the plugin directory separate (and under it's own version control). And removing and adding the plugin should - at least theoretically - not lose changes to the plugin.
The approach should work equally for iOS plugins.
Beware that I have no idea whether or how --link works on Windows machines.
Hint: I found this option in the help:
cordova help plugin
which gives:
[...] [--link] ... when installing from a local path, creates a symbolic link to the plugin instead of copying files. The extent to which files are linked vs copied varies by platform. Useful for plugin development.