2012-01-06 04:33:26 +08:00
|
|
|
Cordova Android
|
2011-08-19 09:21:51 +08:00
|
|
|
===
|
|
|
|
|
2013-01-24 04:17:42 +08:00
|
|
|
Cordova Android is an Android application library that allows for Cordova-based
|
|
|
|
projects to be built for the Android Platform. Cordova based applications are,
|
|
|
|
at the core, applications written with web technology: HTML, CSS and JavaScript.
|
2012-01-06 04:33:26 +08:00
|
|
|
|
2013-01-24 04:21:49 +08:00
|
|
|
Apache Cordova is a project at The Apache Software Foundation (ASF).
|
2009-11-25 07:11:32 +08:00
|
|
|
|
2013-01-24 10:31:30 +08:00
|
|
|
|
2011-08-20 13:20:53 +08:00
|
|
|
Requires
|
2011-08-19 09:21:51 +08:00
|
|
|
---
|
|
|
|
|
2012-09-26 01:09:40 +08:00
|
|
|
- Java JDK 1.5 or greater
|
|
|
|
- Apache ANT 1.8.0 or greater
|
2011-08-20 13:20:53 +08:00
|
|
|
- Android SDK [http://developer.android.com](http://developer.android.com)
|
2012-05-08 06:52:34 +08:00
|
|
|
- Apache Commons Codec [http://commons.apache.org/codec/](http://commons.apache.org/codec/)
|
2012-01-18 05:31:08 +08:00
|
|
|
|
2012-05-08 07:30:24 +08:00
|
|
|
Test Requirements
|
|
|
|
---
|
|
|
|
- JUnit - [https://github.com/KentBeck/junit](https://github.com/KentBeck/junit)
|
|
|
|
|
2012-01-18 05:31:08 +08:00
|
|
|
Building
|
|
|
|
---
|
|
|
|
|
2012-05-08 06:52:34 +08:00
|
|
|
To create your cordova.jar, copy the commons codec:
|
2012-05-10 06:32:53 +08:00
|
|
|
|
2012-12-03 10:19:58 +08:00
|
|
|
mv commons-codec-1.7.jar framework/libs
|
2012-05-08 06:52:34 +08:00
|
|
|
|
|
|
|
then run in the framework directory:
|
2012-01-18 05:31:08 +08:00
|
|
|
|
2012-12-03 10:19:58 +08:00
|
|
|
android update project -p . -t android-17
|
2012-01-18 05:31:08 +08:00
|
|
|
ant jar
|
|
|
|
|
|
|
|
|
2012-01-06 04:33:26 +08:00
|
|
|
Cordova Android Developer Tools
|
2011-08-19 09:21:51 +08:00
|
|
|
---
|
2010-01-27 09:58:27 +08:00
|
|
|
|
2012-01-06 04:33:26 +08:00
|
|
|
The Cordova developer tooling is split between general tooling and project level tooling.
|
2011-09-02 05:44:02 +08:00
|
|
|
|
2012-05-08 03:31:24 +08:00
|
|
|
To enable the command-line tools available in the ./bin directory, make
|
|
|
|
sure you have all of the dependencies installed. You will need
|
|
|
|
[NodeJS](http://nodejs.org) (which should come with `npm`). To install
|
|
|
|
the dependencies:
|
|
|
|
|
|
|
|
$ cd bin
|
|
|
|
$ npm install
|
|
|
|
|
2011-11-01 10:14:05 +08:00
|
|
|
General Commands
|
2010-08-31 07:02:47 +08:00
|
|
|
|
2012-01-06 04:33:26 +08:00
|
|
|
./bin/create [path package activity] ... create the ./example app or a cordova android project
|
2011-09-02 05:44:02 +08:00
|
|
|
./bin/bench ............................ generate a bench proj
|
|
|
|
./bin/autotest ......................... test the cli tools
|
2011-08-19 09:31:13 +08:00
|
|
|
./bin/test ............................. run mobile-spec
|
2011-09-02 05:44:02 +08:00
|
|
|
|
|
|
|
Project Commands
|
|
|
|
|
2012-01-06 04:33:26 +08:00
|
|
|
These commands live in a generated Cordova Android project.
|
2011-09-02 05:44:02 +08:00
|
|
|
|
2012-09-11 03:05:57 +08:00
|
|
|
./cordova/debug [path] ..................... install to first device
|
2012-02-02 09:45:49 +08:00
|
|
|
./cordova/emulate .......................... start avd (emulator) named default
|
|
|
|
./cordova/log .............................. starts logcat
|
2011-08-19 09:31:13 +08:00
|
|
|
|
2011-08-19 13:40:09 +08:00
|
|
|
Running the Example Project
|
2011-08-20 13:20:53 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
Start avd (emulator) named `default`:
|
2011-08-19 09:31:13 +08:00
|
|
|
|
2011-08-19 09:21:51 +08:00
|
|
|
./bin/emulate
|
2010-08-31 07:02:47 +08:00
|
|
|
|
2011-11-01 10:14:05 +08:00
|
|
|
Create the example project and build it to the first device:
|
2011-08-20 13:20:53 +08:00
|
|
|
|
|
|
|
./bin/create
|
2011-09-02 05:44:02 +08:00
|
|
|
cd example
|
2012-02-02 09:45:49 +08:00
|
|
|
./cordova/debug
|
2011-08-20 13:20:53 +08:00
|
|
|
|
|
|
|
Start adb logcat (console.log calls output here):
|
2011-08-19 09:31:13 +08:00
|
|
|
|
2012-02-02 09:45:49 +08:00
|
|
|
./cordova/log
|
2009-12-23 08:01:54 +08:00
|
|
|
|
2012-01-06 04:33:26 +08:00
|
|
|
Creating a new Cordova Android Project
|
2011-11-01 10:14:05 +08:00
|
|
|
---
|
2011-08-19 13:40:09 +08:00
|
|
|
|
2012-09-04 02:10:00 +08:00
|
|
|
./bin/create ~/Desktop/myapp com.myapp.special MyApp
|
2011-08-19 13:40:09 +08:00
|
|
|
|
2012-01-06 04:33:26 +08:00
|
|
|
Importing a Cordova Android Project into Eclipse
|
2011-08-20 13:20:53 +08:00
|
|
|
----
|
2010-01-28 07:11:25 +08:00
|
|
|
|
|
|
|
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)
|
2012-02-02 09:45:49 +08:00
|
|
|
4. Right click on libs/cordova.jar and add to build path
|
2010-01-28 07:11:25 +08:00
|
|
|
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)
|
|
|
|
|
2012-05-17 07:13:46 +08:00
|
|
|
Running Tests
|
|
|
|
----
|
2012-06-01 07:01:20 +08:00
|
|
|
Please see details under test/README.md.
|
2010-08-31 07:02:47 +08:00
|
|
|
|
2011-08-20 13:20:53 +08:00
|
|
|
Further Reading
|
2010-08-31 07:02:47 +08:00
|
|
|
---
|
|
|
|
|
2011-08-20 13:20:53 +08:00
|
|
|
- [http://developer.android.com](http://developer.android.com)
|
2012-09-04 02:10:00 +08:00
|
|
|
- [http://incubator.apache.org/cordova/](http://incubator.apache.org/cordova/)
|
|
|
|
- [http://wiki.apache.org/cordova/](http://wiki.apache.org/cordova/)
|