su - emerge -av nodejs dev-java/ant [ebuild N ] dev-java/ant-1.9.2 USE="X antlr bcel bsf commonslogging commonsnet -jai javamail jdepend -jmf jsch log4j oro regexp resolver -testutil" 0 kB npm install -g phonegap
Install Android
wget tar -zxf echo "\$PATH:~/adv...." >> ~/.bashrc
Making the Project
phonegap create MyNewProject cd MyNewProject
Most Android SDK documentation is oriented towards Eclipse IDE and it follows that examples / instructions for PhoneGap would be as well. But, not everyone uses Eclipse. Here's how to do this stuff from the command line, so you can use what-ever editor you choose (*cough* jEdit).
Environment
The expected environment for these examples is:
- Some 64bit Linux System (we have 3.0.6 kernel, glibc-2.13, ant-1.8.1, jdk-1.6.0.29)
- Android SDK
- PhoneGap >= 1.2.0
- Command Line Experience
- Editor of Choice
Creating the Project
Creating the new Android+PhoneGap project is super easy. Make a directory to hold the project, run the create tool, import PhoneGap
mkdir ~/moile-dev/apgex/ cd ~/moile-dev/apgex/ android create project \ --name 'Android_PhoneGap_EXample' \ --target 12 \ --path . \ --package 'com.edoceo.apgex' \ --activity 'APGEX_Activity'
The project will be created in the current directory. The parameter (12) for target was determined by the output from android list targets
.
The output from that will have numerous IDs, and platforms identified.
On the example system the target identifier of 12 represents Android 2.3.3 (android-10).
Integrating PhoneGap
The project create above is a base-line Android application, which could be coded now as a fully native application. Now we'll integrate PhoneGap, which we'll finally build our application with.
Note: this used to be managed by a tool called droidgap, which is no longer around.
Now, we simply clone the Sample and start hacking
rsync -av ~/phonegap-1.3.0/Android/Sample/ ~/mobile-dev/apgex/
Hacking the Sample
Now we'll surely want to update the Sample code-base with project specific items. The following list shows a few files that should be modified.
- ./AndroidManifest.xml
- ./res/drawable/icon.png
- ./res/drawable-hdpi/ic_launcher.png
- ./res/drawable-ldpi/ic_launcher.png
- ./res/drawable-mdpi/ic_launcher.png
- ./res/layout/main.xml
- ./res/values/strings.xml
From Scratch
Update Manifest, Install PhoneGap
Make asset Dirs Install PhoneGap JAR and phoneGap JS telnet localhost 5554 emulator-arm -a VMD_NAME