Setup Cordova and Android for App development
A quick checklist to setup Cordova (PhoneGap) and Android to create Mobile Apps on a MacBook Pro running Mavericks.
Setup the environment
- Install software
- Install Cordova (PhoneGap):
-
npm install -g cordova
- Install Android-SDK:
-
brew install android-sdk
- Install Java 7 and setup JAVA_HOME:
-
Install Oracle Java: These instructions are from the Oracle website.
- Install Ant:
-
brew install ant
Add exports to .zshrc and update PATH:
export ANDROID_HOME=/usr/local/opt/android-sdk
export JAVA_HOME="$(/usr/libexec/java_home)"
export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
- Source the shell:
- source ~/.zshrc
- Run the Android app to install the platform tools:
- android
- Install the Android API's for the devices you will run on:
- Android 4.4(API 19), 4.3(API 18) and 4.2(API 17); Install others if you need them.
- Create an Android Virtual Device:
- Create at least one phone and one tablet to test on.
- Galaxy Nexus
- Y - Hardware Keyboard Present
- N - Display a skin
- None to cameras (this can be changed later if need be)
- 2GB SD Card
- Snapshot
- Leave all the others at the defaults
- Nexus 10
- Y - Hardware Keyboard Present
- N - Display a skin
- None to cameras (this can be changed later if need be)
- Snapshot
- 2GB SD Card
- Leave all the others at the defaults
Create an app
Create the cordova environment: These instructions are copied from the Cordova website.
- Create a directory for the app
-
cordova create hello com.example.hello HelloWorld
cd hello
cordova platform add android
cordova build
run "android" from another terminal window and start up one of the emulators
cordova emulate android
This will build a sample app then load and run it on the emulator.