HOWTO: Netbeans and Phonegap
Originally posted over here http://twister.tim-perry.co.uk/blog/2010/02/20/PhoneGap_and_Netbeans the link was down (Google Cache to the rescue :).
Just want to make sure this doesn't get lost. Thanks Tim!
Note: I just did a cheap copy+paste here, if the url above works for you I would advise you to check the original article!
PhoneGap and Netbeans
If you're writing phonegap stuff it's generally easiest to make separate projects for each platform, write the one platform and then pass out the HTML/JS to the others, and write each native bit separately. With this in mind the following instructions are for setting up a Android project, but I imagine it's not too difficult to work out the iPhone steps. At least, I hope so, I'm going to have to do it at some point.
Download and set up the Android SDK. Instructions are all on that page, you can ignore the Eclipse stuff, you need to do the platform stuff.
Download phonegap (I'm using 0.8) and extract it.
Build phonegap. This didn't work for me, so I followed the instructions here. Essentially there are a few typos, and you need to put two semicolons in the right places.
Copy the [phonegap dir]/lib/android/phonegap.js (or min.js, or both) to [phonegap dir]/android/assets/www.
Install nbandroid, a NetBeans plugin for android projects.
By this point you've got all the bits you need to get everything working, and it's just a matter of getting a project made and building in NetBeans. Essentially you make a NetBeans android project, and then splice it together with the [phonegap dir]/android folder:
Make a new android project somewhere, through NetBeans.
Copy the res folder from phonegap/android over the res folder NetBeans just made, and build the NetBeans project. This should create a new R.java
Copy the phonegap/android/src folder over the src folder NetBeans made.
Inside NetBeans go to the Projects window -> Source Packages -> com.phonegap.demo, select all the files, right click and go to Refactor -> Move. Move them into the package that the rest of your project is in.
Copy the libs, assets and AndroidManifest.xml from phonegap/android to the NetBeans project.
Add the jar in the libs folder you just copied to the libraries of the NetBeans project.
Run the Android SDK Manager program and make a new Virtual Device.
At this point the project should build, and running it should start an emulator up, and eventually try and run the demo program. Unfortunately, the demo program will only come up with '…index.html file not found', or similar, because NetBeans doesn't correctly tell the Android SDK to get the Assets from the Assets folder you copied and put the in the apk (Android app package). To fix:
In your NetBeans project open nbproject/build-impl.xml and change the line saying '
' to ' '
Go into nbproject/project.properties and change 'assets.dir=' to 'assets.dir=assets'. En route, add 'assets.available=true'