Import and run a Phonegap 3.0 project with Intellij IDEA 12/13?

android, cordova, intellij-idea

Solution

After phonegap create & build , there is a whole Android project located in %my_project_root%\platform\android

if you don't have the Android SDK at left, use the green icon to add one.

That's all

Problem

Just starting with Phonegap and having some trouble understanding the directory structure and setup (on Windows). I have been able to install and setup phonegap, jdk, android sdk, ant, etc. Using the command line I can now create a new project, edit the source files in `www` , build it and run it on my phone, Android Emulator and even Genymotion . But the one thing that I just can not seem to understand is how I could edit and run the Phonegap project from within Intellij IDEA. All examples and how-tos I can find use the older Phonegap 2.9 structure, which is quite different from 3.0. I enabled and configured all plugins, etc. I then try to import the existing project folder as a new project in IDEA, but it says `"Source files for your project not found"`. But when I build the project first with `phonegap build android` using the CLI, and then try to import it in IDEA, source files are found and I can continue the import of the project. But the Project Structure then seems to point to source files in `platforms/android` (`platforms/android` itself and also `platforms/android/gen` and `platforms/android/src` , I have no idea what to choose, so I choose all). I then click Next a couple of times until the Android project is created. After changing Project Language Level to 5 (no idea what this means) , I can now run the project from within IDEA. But... changes that I make in `www` (in the root) don't end up in the compiled project! So do I have to copy all files manually to `platforms/android/assets` then ? (the command line phonegap builder did not require this). Or do I have to edit the files in `platforms/android/assets/www` directly ? (which seems odd, since I would like to be able to only maintain the same code for all different platforms). What do I need to do to achieve this in IDEA? Somehow I think some things in `Project Structure` are wrong, but I have no idea what all this means (Modules, Libraries, Facets....). Where should the manifest file be located, and the resources, and assets and libs?! Could anyone point me in the right direction?

Original source