Setting Up An Android App Build Environment With Eclipse, Android SDK, PhoneGap (Ubuntu 10.10) - Page 3

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Tue, 2011-01-25 17:46. ::

5 Installing PhoneGap

To install PhoneGap, open Firefox and go to https://github.com/phonegap/phonegap-android. Click on the Downloads button:

Select Download .tar.gz from the overlay that comes up:

In the Firefox download dialogue, please choose Save File:

After the download has finished, go to the directory where the download has been saved (e.g. ~/Downloads/):

cd ~/Downloads/

Take a look at the directory's contents to learn how the PhoneGap download is named:

ls -l

falko@falko-desktop:~/Downloads$ ls -l
total 11184
-rw-r--r-- 1 falko falko 11452333 2011-01-24 15:40 phonegap-phonegap-android-0.9.3-21-gee01b50.tar.gz
falko@falko-desktop:~/Downloads$

As you see, in my case it is named phonegap-phonegap-android-0.9.3-21-gee01b50.tar.gz. Now lets uncompress the file:

tar xvfz phonegap-phonegap-android-0.9.3-21-gee01b50.tar.gz

In my case this creates the directory phonegap-phonegap-android-ee01b50 inside the Downloads directory. I want to move that directory to my home directory and rename it to phonegap-phonegap-android:

mv phonegap-phonegap-android-ee01b50 ~/phonegap-phonegap-android

We must add the bin directory inside $HOME/phonegap-phonegap-android to our PATH variable, therefore we edit ~/.profile again:

cd ~
gedit ~/.profile

Replace the previously added PATH variable with this one:

[...]
PATH="$HOME/android-sdk-linux_86/tools:$HOME/android-sdk-linux_86/platform-tools:$HOME/phonegap-phonegap-android/bin:$PATH"

To make the change effective, run:

export PATH="$HOME/android-sdk-linux_86/tools:$HOME/android-sdk-linux_86/platform-tools:$HOME/phonegap-phonegap-android/bin:$PATH"

Now we are finished with setting up our Android development environment; finally we can start doing things with it!

 

6 Starting An Android Emulator

The Android SDK comes with an emulator so that you can test your apps in the emulator instead of on a real Android device. To create an emulator, we first need to know which Android versions (targets) are available:

android list targets

falko@falko-desktop:~$ android list targets
Available Android targets:
id: 1 or "android-3"
     Name: Android 1.5
     Type: Platform
     API level: 3
     Revision: 4
     Skins: HVGA-L, HVGA-P, QVGA-L, HVGA (default), QVGA-P
id: 2 or "android-4"
     Name: Android 1.6
     Type: Platform
     API level: 4
     Revision: 3
     Skins: WVGA854, WVGA800, HVGA (default), QVGA
id: 3 or "android-7"
     Name: Android 2.1-update1
     Type: Platform
     API level: 7
     Revision: 2
     Skins: WVGA854, WQVGA432, WQVGA400, WVGA800, HVGA (default), QVGA
id: 4 or "android-8"
     Name: Android 2.2
     Type: Platform
     API level: 8
     Revision: 2
     Skins: WVGA854, WQVGA432, WQVGA400, WVGA800, HVGA (default), QVGA
id: 5 or "android-9"
     Name: Android 2.3
     Type: Platform
     API level: 9
     Revision: 1
     Skins: WVGA854, WQVGA432, WQVGA400, WVGA800, HVGA (default), QVGA
falko@falko-desktop:~$

I will now create an emulator called mySim for Android 2.2 (id 4 or android-8):

android create avd -n mySim -t android-8

(The emulator for Android 2.3 seems to be buggy; the apps I built for 2.3 crashed immediately after starting them, while they run fine on 2.2; therefore I use Android 2.2 here.)

falko@falko-desktop:~$ android create avd -n mySim -t android-8
Android 2.2 is a basic Android platform.
Do you wish to create a custom hardware profile [no]
<-- ENTER
Created AVD 'mySim' based on Android 2.2,
with the following hardware config:
hw.lcd.density=160
falko@falko-desktop:~$

To start the emulator, run:

emulator -avd mySim

It can take a few minutes until the emulator is up and running, but then it should look as follows:


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.