Android Emulator Setup
emulator-hvga-p.png

Introduction

With a proper emulator set up you can mimic normal device operations to test your application. Because testing of device features requires both a separate user set of preferences per concurrently operating emulator and etc I am describing the details in sequence that you would normally follow to set this up with each emulator.

First install the Android SDK for your Operating System following directions specific for your Operating System. Those on Linux are obviously putting an export PATH entry in their .bashrc file to point to the Android Tools SDK directory. You are only setting path for your first emulator install instance not the other ones. The other emulator instances can be triggered by a user shell or build script tool.

Emulator Command Line Options

With the Android emulator there are two command line groups of commands one uses the user shell command line to give the underlying gemu emulator commands and the other group of commands through the console via telnet modifies emulator features. Lets start with the emulator command line options that are commonly used.

Disk Images

-cache <filepath>
-data <filepath>
-sdcard <filepath>

cache and data are *.img files while sdcard is an *.iso file.

Debug

-logcat <logtags>

Network

-netdelay <delay>

The current network values you can set are gprs, edge, and utms.
-netspeed <speed>

The speed values can be gsm, hscsd, gprs, edge, utms, and hsdpa.

System

I usually do not set the

-cpu-delay <delay>

because my system running at 2.8GHZ with the Android Emulator which uses a Java VM to run is close to the speed perrfomnce wise of the Android G1 approximately.
-timezone <timezone>

Time zones are in zoneinfo format for example America/Chicago

UI

-no-boot-anim

You can disable the boot animation sequence to speed start up of the emulator.
-scale <scale>

If you are making video of the demos using the emulator you can adjust the emulator window size and it has a value between 0.1 and 3.

User Runtime Images

User preferences that are accessible across user sessions can only be saved on concurrent operating emulators if you use a user runtime image setup simulating the SD card. Thus, it is imperative that you know how to setup such a simulated SD image and how to start the emulator with using such an image.

SD Image SetUp

mksdcard 2048M filename.iso

Get a user shell from the directory you will store the sdcard iso in and change the above command to reflect the size you want and the filename you want to use.

User Data Image SetUp

No set up required as when you use the emulator command lien option

-data <filepath>

the emulator will create a fiel if a file does not exist just give it a file path and a filename that you want to use.

Cache Image SetUp

The SD image is not the only user runtime image you need to setup as the browser cache gets store in one specified by the cache filepath command and if not specified is store as temp file that gets deleted when emulator is turned off thus defeating the purpose of emulating the browser cache to be saved across user sessions.

Using the emulator command at emulator start up of:

-cache <filepath>

should be the only setup required.

Emulator Console

The emulator console gives use the power to configure an operating emulator to mimic device features and functions such as network, gps, telephony, and etc. Remember that you can also use a build script to execute a console shell and send these console commands to set up an emulator once it has started as well.

You use the command of:

telnet localhost <console-port>

with the port being between 5554 and 5572 even numbers only as the adb is on odd port numbers. Once the telnet connection is established you can send console commands to the running emulator.

Useful Emulator Console Line Options

Network SetUp

Unless yu are doing something special you shoudl not have ot modify the network setup with redirects and etc.

GPS SetUp

The GPS is set up by sending a emulator console command of:

geo <fix|nmea>

Fix can be in form of
fix <longitude> <latitude> [<altitude>]

The nmea portion of the geo command is for those android devices that have an external gps attached and the command is:

nmea <sentence>

Remember you can on the desktop use GoogleEarth to set a route and save that as kml and load back into the emulator to give a simulated gps path of travel. See the article references for details.

References

  1. Android Emulator Docs at GoogleCode
  2. Installing Google Android SDK 1.0 On Ubuntu 8.04 Desktop
  3. Changing the default GPS Route
Page tags: android emulator mobile
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License