How to build Android app using Ant
Build an Android app locally with enabling Android specific features. Don't use this output to replace other platform's
www
content (ex: enabled Swipe Up and Down).
Procedure 3. Install and configure Android
Download the Android SDK from developer site.
Extract it into directory where you like to install it. Ex: it extracted as
android-sdk-linux
in linux.Execute the file :
On Windows, double-click the SDK Manager.exe file at the root of the Android SDK directory.
On Mac or Linux, open a terminal and navigate to the tools/ directory in the Android SDK, then execute android sdk
Ex: In Linux,execute the file android in tools directory which is inside extracted folder
android-sdk-linux/tools/android
. Then add Platforms and Packages.Add the directories which include "
android
" and "adb
" into PATH variables. ( those will be inandroid-sdk-<OS>/tools
andandroid-sdk-<OS>/platform-tools
)
Create an Android project
Create Mobile Output for Android
Locate in
mobile
directory and run command using terminal :$ ant mobile.android
This will create chunk of html files which can use to build Android app using PhoneGap.
Warning
The bash scripts file
mobile/android/bin/create
has some modification from orginal PhoneGap package file. This is due to unexpected behaviour and some syntax errors while running on Linux. Current script is successfullly running on Ubuntu-12.04 64bit. Any changes that add to orginal script commented out in a way that user can identified those with "docbook" tag. On any error, change them into previous bash lines.Important
IMPORTANT : The current script,always perform with newest sdk on your machine. If you want to decide the version, then change the line of
android/bin/create
shell script file:TARGET=$($ANDROID_BIN list targets \ | grep id: | tail -1 | cut -f 2 -d ' ' )
with
TARGET=<target_number>
. This means the platform number of Android target vertion which is given under
$ android list targets
Please refer for more details about Managing AVDs.
Warning
Also check the "Type: Platform", but not "Type: Add-on".
Run the create command with the following parameters:
Path to your new Cordova Android project
Package name, following reverse-domain style convention
Project name
$ ./path/to/cordova-android/bin/create \ /path/to/my_new_cordova_project \ com.example.cordova_project_name \ CordovaProjectName
Ex: $ bin/create ~/Desktop/Mobile \ docbook.xsl.Mobile Mobile
This command creates Android apps called "Mobile" in
~/Desktop/Mobile
directory with "docbook/xsl/Mobile.java" class in Android project'ssrc
directory.on windows
$ path\to\cordova-android\bin\create.bat ^ path\to\my_new_cordova_project ^ com.example.cordova_project_name ^ CordovaProjectName
Ex: $ bin/create.bat Android xsl.Mobile DocBook
This command creates Android apps called "DocBook" in
Android
directory(in the current directory) with "xsl/Mobile.java" class in Android project'ssrc
directory.
Important
Go to newly created Android project path/to/my_new_cordova_project
and replace path\to\my_new_cordova_project/asserts/www
directory with mobile/www
directory.