mameau redbubble image
Get Shirty!Keep us online, Buy some kit.

PhoneGap 3.3 on Ubuntu 12.04/14.04/Mint17 from download to ‘run android’

You can build mobile apps with the tools you are already used too,

PhoneGap is an opensource framework to build cross-platform mobile apps using HTML5, CSS and JS. Using these tools may be of interest to those of us already in the web development pool. The project itself has ties to Adobe, what that means for the future is unknown. With corporate backing I expected a simpler install process but what I found was ‘too many’ problems getting Phonegap up and running, so for the rest of us here are the steps It took me to get up and running with PhoneGap from download to ‘run android’

Firstly we need to install Node.js, PhoneGap 3.3 requires Node.js 0.8+ but as you’ll soon find, using the standard repositories 12.04 only provides Node.js 0.6. You could install the archive available on the Node.js homepage but thanks to Chris Lea this is simplified by the use of a ppa.

Requirements (+Version)

Before you begin open a Terminal window, this may be achieved by pressing CTRL+ALT+T keys simultaneously.

1.) Add the Node.js ppa, and install the nodejs package. (At the time of writing you will download 10.25 from the ppa)

$ sudo add-apt-repository ppa:chris-lea/node.js
$ sudo apt-get update
$ sudo apt-get install nodejs

Installing Node.js will give you the npm command needed to install PhoneGap, now that you have the npm command available you  can install PhoneGap through the npm command (may need sudo/root access)

$ npm install -g phonegap

Error 503 or 400? Read our guide on how to change the default npm registry

2.) Add the Android ADT bundle

Download the ADT bundle for your version of Linux

Extract the ADT bundle (we will extract to a build/ directory under home in this example)

$ mkdir -p ~/build/
$ tar xvf android-sdk_r22.3-linux.tgz -C ~/build/

3.) Add the Android SDK to your path

$ nano ~/.bashrc

Add this line to the bottom of the ~/.bashrc file and save the file

export PATH=${PATH}:$HOME/build/android-sdk-linux/platform-tools/:$HOME/build/android-sdk-linux/tools

Close the terminal window and reopen for the changes to take effect.

Install the version 19 Android SDK

$ android

In the Android SDK Manager check all packages for version 19 or 19.0.1 (At the time of writing) and press the “Install packages…” button on the bottom right.

4.) Install Ant

$ sudo apt-get install ant

5.) Create an Android Virtual Device (AVD)

The device emulator will run the AVD during development, you will need to understand what targets are installed (i.e. the version of android the AVD will run) .

$ android list targets

Obtain the ID number of the target from the output, in my case 1, with the target ID known you may create the Android Virtual Device.

$ android create avd --name phonegap --target 1

When asked if you would like to create a custom hardware configuration answer “No” to keep it simple.

If you receive an invalid –tag error, add the –abi switch to the command line with the profile from the tags section of the output you wish to target (encapsulated in quotations)

$ android create avd --name phonegap --target 1 --abi "android-wear/armeabi-v7a"

6.) Install Oracle Java SE

My current version of installed Java before starting this process was

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

Everything ‘appears’ to work correctly for me at this stage, I will review this post if that proves otherwise (let me know in the comments if you experience problems)

I had pre-installed java from the WebUpd8 ppa

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java7-installer

7.) Finished

After these steps you will be ready to develop with PhoneGap, create the test app as listed on the site

$ phonegap create my-app
$ cd my-app
$ phonegap run android

PhoneGap will compile an android package and install it onto the emulator, the emulator will then start and the package will execute

Show Buttons
Hide Buttons