You are on page 1of 7

PHONEGAP - HOW TO?

Prerequisites -
1. Node.js
2. Android SDK
3. Java Development Toolkit (JDK)
4. Apache ANT
Installing Node.js-
1. Go to www.nodejs.org

2. Select INSTALL and follow the instructions.
Installing Android SDK-
1. Go to developer.android.com/sdk/index.html

2. Select DOWNLOAD THE SDK(ADT BUNDLE FOR WINDOWS)

3. Read the terms & conditions and Select your system type(32-bit or 64-bit) to download.
4. Once the download is finished, extract the contents of the downloaded file to a workspace where
you're going to build the project.
Installing Java Development Toolkit(JDK)-
1. Go to http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-
1880260.html

2. Read and Accept Licence Agreement.
3. Download the file based on your system type(x86 for 32-bit machine and x64 for 64-bit machine).
4. Run the downloaded file and follow the installation instructions.

Installing Apache ANT-
1. Go to http://ant.apache.org/bindownload.cgi

2. Download the .zip archive by clicking apache-ant-1.9.3-bin.zip
3. Once the download is finished, extract the contents of the downloaded file to a workspace where
you're going to build the project.
Set Environment Variables-
1. Go to Start Menu.
2. Right-click Computer and Select Properties.

3. Go to "Advanced System Settings".

4. Select Environment Variables.

5. Under User Variables, Select New and add the following pairs.
ANDROID_HOME = yourandroidsdklocation\adt-bundle-windows-x86_64-20131030\sdk
ANT_HOME = yourapacheantlocation\apache-ant-1.9.3-bin\apache-ant-1.9.3
JAVA_HOME = yourjavalocation\Java\jdk1.7.0_51
6. Add the following to the PATH.
PATH = ;%JAVA_HOME%\bin;%ANT_HOME%\bin;%ANDROID_HOME%\platform-
tools;%ANDROID_HOME%\tools;
Installing Cordova and PHONEGAP-
1. Make sure that you're connected to the internet.
2. Go to the node.js command prompt.
3. Type the following to download cordova.
npm install -g cordova
4. Type the following to download phonegap.
npm install -g phonegap
*npm - Node.js package manager to install node programs.
*-g - to install globally.
Create your first Application-
1. To create your first app, open command prompt and type the following.
cordova create hello com.example.hello HelloWorld
OR
phonegap create hello com.example.hello HelloWorld
*hello - folder name
*com.example.hello - package name
*HelloWorld - Application Name
Add Platforms-
1. Open Command Prompt and go to Project folder (hello).
2. To add ANDROID platform, type
cordova platform add android
Similarly, other platforms can be added but first download the respective SDKs.
Check set of Platforms Available -
1. Open Command Prompt and go to Project folder (hello).
3. To check platforms, type
cordova platforms ls
Build the Application-
1. Open Command Prompt and go to Project folder (hello).
2. To build, type
cordova build
3. To build platform specific, type
cordova build platform-name
For, android - cordova build android
build is the shortcut for cordova prepare android; cordova compile android
Run Application-
1. To run on a Virtual Device/Emulator, first create the Emulator.
For Android, create Android Virtual Device.
Refer to the following links to create AVD -
Using AVD Manager - http://developer.android.com/tools/devices/managing-avds.html
Using Command Line - http://developer.android.com/tools/devices/managing-avds-cmdline.html
2. After creating the Virtual Device/Emulator, go to the Project folder and type the following-
cordova emulate android
3. To run on a Real Device, connect your device to the system.
4. Make sure that you can use your device for Development/Testing.
In android, check for Developer Options.

5. Once your device is setup, go to the project folder and type the following-
cordova run android

You might also like