Web & HTTP‎ > ‎

PhoneGap

Installing on Ubuntu Linux

Prerequisites

Install Java JDK, NodeJS, npm & Ant

sudo apt-get install openjdk-7-jdk nodejs npm ant

The binary when you install nodejs from the Ubuntu packages is /usr/bin/nodejs.  However the PhoneGap scripts expect it to be /usr/bin/node.  To correct this make a symlink so that we have bot nodejs and node

sudo ln -s /usr/bin/nodejs /usr/bin/node

Install Android SDK, and add the to the path the tools and platform-tools directory from the SDK.
I usually install the Android ADT-Bundle - this includes everything you will need including the SDK
The best way to add the SDK to your path is to place the following in your .profile.  Editing the first line to the location that the SDK is installed in.
I usually leave the first line as it is, and use a symlink to the location.  That way I can change SDK,and just change the symlink

ANDROID_HOME=${HOME}/adt-bundle-linux/sdk
if [ -d "${ANDROID_HOME}/tools" ] ; then
    export PATH="${PATH}:${ANDROID_HOME}/tools" 
fi
if [ -d "${ANDROID_HOME}/platform-tools" ] ; then
    export PATH="${PATH}:${ANDROID_HOME}/platform-tools"
fi

NOTE:
 if you used the ADT Bundle, the SDK is in a directory under the location you extracted the files. (See ANDROID_HOME on line one above)
make sure that you can run android, (It's in the sdk/tools directory) and then make sure that the latest platform and tools are downloaded
For PhoneGap 3.3 you will need at least the 2013-10-30 SDK/ADT and you will need to have run android to download the tools and API 19 components
NOTE:  You may need to manually start  SDK Manager from the SDK directory
NOTE:  You will also have to run AVD Manager.exe to define the emulated devices, or you can connect a real android phone if you have one

Install PhoneGap

$ sudo npm install -g phonegap@3.4

Install Codova (If required)

$ sudo npm install -g cordova

Install Less

$ sudo npm install -g less

Install Grunt

$ sudo npm install -g grunt-cli

Create your first App

$ cd ~/my-app-dir
$ phonegap create my-app

Buikd and Run the App

$ phonegap run android     # Build and Run
$ phonegap build android   # Build ONLY

Installing on Windows 7

Prerequisites

Oracle Java JDK

Download and Install the Oracle Java JDK : http://www.oracle.com/technetwork/java/javase/downloads/ This should set all the appropriate environment variables and update your path
NOTE: make sure that you select the JDK and not the JRE. We will need the JDK so that PhoneGap can compile some Java.
Make sure that you also set JAVA_HOME to the location of the JDK not the JRE
e.g: JAVA_HOME=C:\Program Files\Java\jdk1.7.0_51 

NodeJS

Download and Install NodeJS and npm from: http://nodejs.org/
When you install NodeJS on windows it will also install npm (nodejs package manager).

Apache Ant

Download Apache Ant: http://ant.apache.org/
Extract to an appropriate directory (I used my home directory)
Create the environment variable ANT_HOME and set it to the location you used for Ant.
Add %ANT_HOME%/bin to your PATH.

Android SDK or ADT Bundle

Download either the Android SDK or the ADT Bundle http://developer.android.com/sdk/index.html
Extract to an appropriate directory( I used my hone directory)
Create the Environment Variable ANDROID_HOME and set to the location you extracted the SDK
NOTE: if you used the ADT Bundle, the SDK is in a directory under the location you extracted the files.
Add %ANDROID_HOME%/platform-tools and %ANDROID_HOME%/tools to your PATH
make sure that you can run android, (It's in the sdk\tools directory) and then make sure that the latest platform and tools are downloaded
For PhoneGap 3.3 you will need at least the 2013-10-30 SDK/ADT and you will need to have run android.bat to download the tools and API 19 components  
NOTE:  You may need to manually start  SDK Manager.exe from the SDK directory
NOTE:  You will also have to run AVD Manager.exe to define the emulated devices, or you can connect a real android phone if you have one

Install PhoneGap

C:\Users\cmartin> npm install -g phonegap

Create your first App

C:\Users\cmartin phonegap create my-app

Run the App

C:\Users\cmartin>$ cd my-app
C:\Users\cmartin\my-app> phonegap run android


Subpages (1): Debugging
Comments