PhoneGap/Android is an Android application library that allows for PhoneGap based projects to be built for the Android Platform. PhoneGap based applications are, at the core, an application written with web technology: HTML, CSS and JavaScript.
- Java JDK 1.5
- Android SDK http://developer.android.com
- Apache ANT
- Ruby (Optional, see section: DroidGap with JRuby)
On OS X add PhoneGap/Android to your PATH variable like so:
export PATH=$PATH:~/phonegap-android/bin
On Windows add the phonegap-android/bin to your PATH as normal.
Useful utilities for developers building mobile apps using PhoneGap for Android.
Usage:
droidgap [command] [parameters]
Commands:
help ...... See this message. Type help [command name] to see specific help topics. gen ....... Generate an example PhoneGap application to current directory. create .... Creates an Android compatible project from a www folder. Careful, this clobbers previous packaging. classic ... Backwards support for droidgap script. Run "droidgap help classic" for more info. run ....... Installs a valid PhoneGap Project to first device found. log ....... Attach a logger that listens for console.log statements. update .... Copy a fresh phonegap.jar and phonegap.js into a valid PhoneGap/Android project. test ...... Gets edge copy of mobile-spec and runs in first device or emulator attached. ship ...... Build and sign an APK suitable for submission to an Android Marketplace.
Quickstart:
$ droidgap gen example $ cd example $ droidgap create $ cd ../example_android $ droidgap run
Launch your app and start a logger with:
$ droidgap log
If you want to use the droidgap command but do not want to install Ruby then you can call it using jruby jar included in the lib folder. All the options are the same and a call looks like this:
java -jar jruby-complete-1.4.0RC1.jar ../bin/droidgap help run
Keep in mind this will be slower due to JVM warmup.
- File > New > Project...
- Android > Android Project
- Create project from existing source (point to the generated app found in tmp/android)
- Right click on libs/phonegap.jar and add to build path
- Right click on the project root: Run as > Run Configurations
- Click on the Target tab and select Manual (this way you can choose the emulator or device to build to)
droidgap test
Make sure you have a device plugged in (with debugging enabled) or a running emulator. Then:
ant debug install
or
droidgap run
Given a Widget called FooBar with an index.html file in it. You navigate to its folder and run:
droidgap create
cd ../FooBar_android
ant debug install
adb devices
List of devices attached
0123456789012 device
apk -s 0123456789012 install phonegap.apk
Via console.log calls from your apps javascript.
adb logcat
Attach it to a process on the device
$ adb jdwp
adb forward tcp:8000 jdwp: jdb -attach localhost:8000