Android – Deploying Phonegap / Cordova app for Android

androidbuildcommand-line-interfacecordovadeployment

I've got a Phonegap/Cordova 3.0 app that I am testing on Android.

Since version 2.x, Cordova relies heavily on the command-line terminal. I've done all the setup stuff and I can build the app. But two things are troubling me.

First of all, an Android project has two www folders. One is [myproject]/www. The other is [myproject]/platforms/android/assets/www. I'm not sure which of these folders to edit when I am fixing bugs.

If I am correct, the first one is where you place your app files before using the command-line "cordova build" to create the app. The second one should then be only a copy that's used after building, before deploying.

Now my question is, when I make a change to my app and I want to test on device, do I have to use the command line to (re)build the app every time?

Best Answer

[myproject]/www is the directory in which you should put your source files. When you build your app these files are copied in to [myproject]/platforms/[platform]/assets/www. In addition to this, files in [myproject]/platforms/[platform] are also copied to [myproject]/platforms/[platform]/assets/www, which allows you to create per-platform overrides to your files.

Note that you should never edit files in [myproject]/platforms/[platform]/assets/www directly, as they will be deleted next time you build your project.

To run your project on your device use cordova run [platform], or to run it on an emulator use cordova emulate [platform].