cordova-android/README.md

129 lines
3.3 KiB
Markdown
Raw Normal View History

2010-01-28 07:00:21 +08:00
PhoneGap/Android
================
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.
2009-11-25 07:11:32 +08:00
2010-08-31 07:02:47 +08:00
Pre Requisites
2010-01-28 07:00:21 +08:00
--------------
- Java JDK 1.5
2010-08-31 07:02:47 +08:00
- Android SDK [http://developer.android.com](http://developer.android.com)
2010-01-28 07:00:21 +08:00
- Apache ANT
2010-08-31 07:02:47 +08:00
- Ruby (Optional, see section: DroidGap with JRuby)
2009-11-25 07:11:32 +08:00
2010-08-31 07:02:47 +08:00
Install
-------
2009-11-25 07:11:32 +08:00
2010-10-07 02:51:42 +08:00
On any POSIX machine add PhoneGap/Android to your PATH variable like so:
2010-08-31 07:02:47 +08:00
export PATH=$PATH:~/phonegap-android/bin
2010-09-01 04:27:43 +08:00
On Windows add the phonegap-android/bin to your PATH as normal.
2010-08-31 07:02:47 +08:00
DroidGap: PhoneGap/Android Dev Script
-------------------------------------
2010-10-07 02:51:42 +08:00
Tools for developers building mobile apps using PhoneGap for Android.
2010-08-31 07:02:47 +08:00
Usage:
<pre>droidgap [command] [parameters]</pre>
Commands:
<pre>
2010-09-06 06:13:32 +08:00
help ...... See this message. Type help [command name] to see specific help topics.
gen ....... Generate the example PhoneGap application to current directory (or optionally provide an output directory as parameter).
2010-10-07 02:51:42 +08:00
create .... Creates an Android compatible project from a WWW folder.
2010-09-06 06:13:32 +08:00
classic ... Backwards support for droidgap script. Run "droidgap help classic" for more info.
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.
2010-08-31 07:02:47 +08:00
</pre>
Quickstart:
<pre>
$ droidgap gen exampleapp
$ cd exampleapp
$ ant debug install && adb logcat
2010-01-28 07:13:26 +08:00
</pre>
2010-08-31 07:02:47 +08:00
DroidGap with JRuby
-------------------
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.
2009-12-23 08:01:54 +08:00
Importing a PhoneGap/Android app into Eclipse
---------------------------------------------
1. File > New > Project...
2. Android > Android Project
2010-08-31 07:02:47 +08:00
3. Create project from existing source (point to the generated app found in tmp/android)
4. Right click on libs/phonegap.jar and add to build path
5. Right click on the project root: Run as > Run Configurations
2010-08-31 07:02:47 +08:00
6. Click on the Target tab and select Manual (this way you can choose the emulator or device to build to)
Common Command Line Tasks
=========================
Running Mobile Spec
---
2010-09-06 06:13:32 +08:00
droidgap test
2010-08-31 07:02:47 +08:00
Compile an APK
---
2010-09-06 06:13:32 +08:00
Make sure you have a device plugged in (with debugging enabled) or a running emulator. Then:
ant debug install
or
droidgap run
2010-08-31 07:02:47 +08:00
Converting a W3C Widget into a an APK
---
2010-09-06 06:13:32 +08:00
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
2010-08-31 07:02:47 +08:00
List devices attached
---
2010-09-06 06:13:32 +08:00
adb devices
2010-08-31 07:02:47 +08:00
List of devices attached
0123456789012 device
Install APK onto device
---
2010-09-06 06:13:32 +08:00
apk -s 0123456789012 install phonegap.apk
2010-08-31 07:02:47 +08:00
Logging
---
Via console.log calls from your apps javascript.
2010-09-06 06:13:32 +08:00
adb logcat
2010-08-31 07:02:47 +08:00
Debugging
---
Attach it to a process on the device
2010-08-31 07:02:47 +08:00
$ adb jdwp
adb forward tcp:8000 jdwp: jdb -attach localhost:8000
For more info see
-----------------
2010-02-15 15:40:35 +08:00
- [http://docs.phonegap.com](http://docs.phonegap.com)
2010-09-01 04:27:43 +08:00
- [http://wiki.phonegap.com](http://wiki.phonegap.com)