The other day I was developing a site for a client who wanted to be sure their new site would work on the Android platform. I don’t own a phone which runs Android so I started looking around for an emulator instead. If you do the same you’ll quickly find the Android Development website which holds a wealth of Android development information aswell as the SDK. This is helpful but I found it wasn’t clear whether this would let me test websites or not. For this reason I’ve put together this quick how-to on getting the Android emulator running on your computer.
What you will need
- The latest Android SDK
- At least version 1.5 of the Java Developer Kit. (type @java -version@ into your terminal or command prompt to find out the version you have).
- About 10 minutes of time
Setting Up
- Follow the instructions on the Android SDK installation page making sure you follow the steps for adding the tools directory to your path. In my case I put the SDK into
~/Code/Android(where~/is my home directory). - Restart your command prompt or terminal and type
android. You should be presented with the android help information. If not check you set the path correctly.
Target Platforms and Android Virtual Devices (AVDs)
It is possible to create emulators (AVDs) for each version (or target) of Android. To do this we need to check which hardware targets are available and what their target ID is. If you type android list targets into your terminal you will be presented with something similar to the code below.
Available Android targets:
id: 1
Name: Android 1.1
Type: Platform
API level: 2
Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
id: 2
Name: Android 1.5
Type: Platform
API level: 3
Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
id: 3
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Description: Android + Google APIs
Based on Android 1.5 (API level 3)
Libraries:
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: HVGA (default), HVGA-L, QVGA-P, HVGA-P, QVGA-L
From this information we can see the SDK supports Android 1.1 and 1.5 and their target IDs are 1 and 2 respectively. Knowing this information we can now create our Android Virtual Device. To create an AVD for Android 1.1 (target ID 1) with the name android1.1 we type:
android create avd -n android1.1 -t 1
Similarly for Android 1.5 we type:
android create avd -n android1.5 -t 2
A few things to know about AVDs.
* When creating AVDs you can use any name you like. I choose android1.1 and android1.5 as they were easier to remember.
* When prompted about hardware settings just press enter as there should be no need to customise the hardware when testing websites.
* AVDs are created in a hidden folder in the root of your home directory. On Linux and MacOS this is ~/.android/avd.
* You can find out what AVDs you have by typing android list avd in the terminal.
Running the Emulator
Having created the AVDs we can now run the emulator by typing emulator -avd avdname. This command is the one you will need to use from now on if you want to test websites in Android. For example, if we want to emulate Android 1.1 we would type:
emulator -avd android1.1
The first time you run the emulator you will be asked if you are happy for Emulator to send usage statistics to Google.

It can take about 10-30 seconds for the Android Emulator to boot up. During this time you will see the Android boot screen.

That’s it! To test your websites just load the Browser from the home screen. To enter a URL click Menu and then select Go or Go to URL depending on the version of Android you are running.

