Skip to content

Instantly share code, notes, and snippets.

@mwbrooks
Created August 18, 2011 05:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwbrooks/1153357 to your computer and use it in GitHub Desktop.
Save mwbrooks/1153357 to your computer and use it in GitHub Desktop.
phonegap-android using CLI
#
# Based on the PhoneGap Android Terminal Quickstart Guide:
# http://wiki.phonegap.com/w/page/30864168/phonegap-android-terminal-quickstart
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Setting up your System
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# It's easier if you have the Android SDK in your PATH.
# You can accomplish this by adding the following line
# to your ~/.bashrc or ~/.profile.
# Your Android SDK path and name be slightly different.
export PATH=$PATH:/Applications/android-sdk-mac/tools/
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Setting up a new Project
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Change into an existing PhoneGap-Android project.
# I use the PhoneGap-Android sample to create new projects.
cd existing/android/project
# List your installed Android SDK targets
# You will want to update the project to
# build to one or more of these SDKs
android list targets
# The output will be similar to:
#
# Available Android targets:
# id: 1 or "android-8"
# Name: Android 2.2
# Type: Platform
# API level: 8
# Revision: 2
# Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854
# id: 2 or "android-12"
# Name: Android 3.1
# Type: Platform
# API level: 12
# Revision: 3
# Skins: WXGA (default)
# Update your project to build to at least one
# of these SDKs. Below, I target the Android 2.2
# SDK (id: 1).
android update project -p . -t 1
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Building and Running your Project
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# First, you will need to connect your Android device
# or launch a simulator. Below, I show how to launch
# the simulator from the command-line
android
# Create a new Android Virtual Device (AVD) or select
# an existing one and click "Start..." on the right-side.
# Once the simulator has booted (or device is connected)
# you can install your application
ant debug install
# Debug will sign the application with debug key. If you have
# setup a release key, then you can run `ant release install`
@revolunet
Copy link

Thanks Michael this works perfectly. Any hint how to include plugins there ?

@mwbrooks
Copy link
Author

Hey,

Glad to hear that it helped!

Including plugins with the above steps should not be a problem. You can place the Java files in existing/android/project/src and the JavaScript in existing/android/project/assets/www. You plugin will then be built into the Android project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment