Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 553
Dylan Avatar asked Aug 18 '13 23:08

Dylan


2 Answers

enter image description here

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

enter image description hereenter image description hereenter image description hereenter image description here

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

enter image description here

That's all

like image 119
bigCat Avatar answered Oct 08 '22 00:10

bigCat


We don't need to modify manually the code under %my_project_root%/platforms/* but only under the %my_project_root%/www/* and %my_project_root%/merges/*

After running

phonegap build android

it automatically replaces platform specified code.

I found solution for me the next way:

After importing source code to IDEA, I added new web module which points to the %my_project_root% to be able to see all needed directories.

Also I created new IDEA command line tool with alias phonegap and tool path /usr/local/share/npm/bin/phonegap.

So before running default android running configuration I run phonegap build android just directly from IDEA (I think it's more convenient) and then run usual android run command to deploy the app to emulator or real device.

I hope this stuff will help you.

like image 27
falinsky Avatar answered Oct 07 '22 22:10

falinsky