Android Emulator: in This Document
Android Emulator: in This Document
Overview
The Android emulator is a QEMU-based application that provides a virtual ARM mobile device
on which you can run your Android applications. It runs a full Android system stack, down to
the kernel level, that includes a set of preinstalled applications (such as the dialer) that you
can access from your applications. You can choose what version of the Android system you
want to run in the emulator by configuring AVDs, and you can also customize the mobile
device skin and key mappings. When launching the emulator and at runtime, you can use a
variety of commands and options to control the its behaviors.
The Android system image distributed in the SDK contains ARM machine code for the Android
Linux kernel, the native libraries, the Dalvik VM, and the various Android package files (such
as for for the Android framework and preinstalled applications). The emulator's QEMU layers
provide dynamic binary translation of the ARM machine code to the OS and processor
architecture of your development machine.
Adding custom capabilities to the underlying QEMU services, the Android emulator supports
many hardware features likely to be found on mobile devices, including:
• An ARMv5 CPU and the corresponding memory-management unit (MMU)
• A 16-bit LCD display
• One or more keyboards (a Qwerty-based keyboard and associated Dpad/Phone
buttons)
• A sound chip with output and input capabilities
• Flash memory partitions (emulated through disk image files on the development
machine)
• A GSM modem, including a simulated SIM Card
The sections below provide more information about the emulator and how to use it for
developing Android applications.
Starting and Stopping the Emulator
During development and testing of your application, you install and run your application in
the Android emulator. You can launch the emulator as a standalone application, from a
command line, or you can use it as part of your Eclipse development environment. In either
case, you specify the AVD configuration to load and any startup options you want to use, as
described in this document.
You can run your application on a single instance of the emulator or, depending on your
needs, you can start multiple emulator instances and run your application in more than one
emulated device. You can use the emulator's built-in commands to simulate GSM phone
calling or SMS between emulator instances, and you can set up network redirections that
allow emulators to send data to one another. For more information, see Telephony
Emulation, SMS Emulation, and Emulator Networking
To start an instance of the emulator from the command line, change to the tools/ folder of the
SDK. Enter emulator command like this:
emulator -avd <avd_name>
This initializes the emulator and loads an AVD configuration (see the next section for more
information about AVDs). You will see the emulator window appear on your screen.
If you are working in Eclipse, the ADT plugin for Eclipse installs your application and starts the
emulator automatically, when you run or debug the application. You can specify emulator
startup options in the Run/Debug dialog, in the Target tab. When the emulator is running, you
can issue console commands as described later in this document.
If you are not working in Eclipse, see Installing Applications on the Emulator for information
about how to install your application.
To stop an emulator instance, just close the emulator's window.
Android Virtual Devices and the Emulator
To use the emulator, you first must create one or more AVD configurations. In each
configuration, you specify an Android platform to run in the emulator and the set of hardware
options and emulator skin you want to use. Then, when you launch the emulator, you specify
the AVD configuration that you want to load.
To specify the AVD you want to load when starting the emulator, you use the -avd argument,
as shown in the previous section.
Each AVD functions as an independent device, with its own private storage for user data, SD
card, and so on. When you launch the emulator with an AVD configuration, it automatically
loads the user data and SD card data from the AVD directory. By default, the emulator stores
the user data, SD card data, and cache in the AVD directory.
To create and manage AVDs you use the android tool, a command-line utility included in the
SDK. For complete information about how to set up AVDs, see Android Virtual Devices.
Controlling the Emulator
You can use emulator startup options and console commands to control the behaviors and
characteristics of the emulated environment itself.
When the emulator is running, you can interact with the emulated mobile device just as you
would an actual mobile device, except that you use your mouse pointer to "touch" the
touchscreen and your keyboard keys to "press" the simulated device keys.
The table below summarizes the mappings between the emulator keys and and the keys of
your keyboard.
Emulated Device Key Keyboard Key
Home HOME
Menu (left softkey) F2 or Page-up button
Star (right softkey) Shift-F2 or Page Down
Back ESC
Call/dial button F3
Hangup/end call button F4
Search F5
Power button F7
Audio volume up button KEYPAD_PLUS, Ctrl-5
Audio volume down button KEYPAD_MINUS, Ctrl-F6
Camera button Ctrl-KEYPAD_5, Ctrl-F3
Switch to previous layout orientation (for KEYPAD_7, Ctrl-F11
example, portrait, landscape)
Switch to next layout orientation (for example, KEYPAD_9, Ctrl-F12
portrait, landscape)
Toggle cell networking on/off F8
Toggle code profiling F9 (only with -trace startup option)
Toggle fullscreen mode Alt-Enter
Toggle trackball mode F6
Enter trackball mode temporarily (while key is Delete
pressed)
DPad left/up/right/down KEYPAD_4/8/6/2
DPad center click KEYPAD_5
Onion alpha increase/decrease KEYPAD_MULTIPLY(*) /
KEYPAD_DIVIDE(/)
Note that, to use keypad keys, you must first disable NumLock on your development
computer.
Emulator Startup Options
The emulator supports a variety of options that you can specify when launching the emulator,
to control its appearance or behavior. Here's the command-line usage for launching the
emulator with options:
emulator -avd <avd_name> [-<option> [<value>]] ... [-<qemu args>]
The table below summarizes the available options.
Categ Option Description Comments
ory
Help -help Print a list of all emulator
options.
-help-all Print help for all startup
options.
-help-<option> Print help for a specific
startup option.
-help-debug- Print a list of all tags for -
tags debug <tags>.
-help-disk- Print help for using
images emulator disk images.
-help- Print help for emulator
environment environment variables.
-help-keys Print the current mapping
of keys.
-help-keyset- Print help for defining a
file custom key mappings file.
-help-virtual- Print help for Android
device Virtual Device usage.
AVD -avd Required. Specifies the You must create an AVD configuration
<avd_name> or AVD to load for this before launching the emulator. For
@<avd_name> emulator instance. information, see Android Virtual
Devices.
Disk -cache <filepath> Use <filepath> as the Optionally, you can specify a path
Image working cache partition relative to the current working
s image. directory. If no cache file is specified,
the emulator's default behavior is to
use a temporary file instead.
For more information on disk images,
use -help-disk-images.
-data <filepath Use <filepath> as the Optionally, you can specify a path
> working user-data disk relative to the current working
image. directory. If -data is not used, the
emulator looks for a file named
"userdata-qemu.img" in the storage
area of the AVD being used (see -avd).
-initdata <filep When resetting the user- Optionally, you can specify a path
ath> data image (through -wipe- relative to the current working
data), copy the contents of directory. See also -wipe-data.
this file to the new user- For more information on disk images,
data disk image. By use -help-disk-images.
default, the emulator
copies
the <system>/userdata.im
g.
-nocache Start the emulator without See also -cache <file>.
a cache partition.
-ramdisk <filep Use <filepath> as the Default value
ath> ramdisk image. is <system>/ramdisk.img.
Optionally, you can specify a path
relative to the current working
directory. For more information on
disk images, use -help-disk-images.
-sdcard <filepa Use <file> as the SD card Default value
th> image. is <system>/sdcard.img.
Optionally, you can specify a path
relative to the current working
directory. For more information on
disk images, use -help-disk-images.
-wipe-data Reset the current user-data See also -initdata.
disk image (that is, the file For more information on disk images,
specified by -datadir and - use -help-disk-images.
data, or the default file).
The emulator deletes all
data from the user data
image file, then copies the
contents of the file at -
inidata data to the image
file before starting.
Debug -debug <tags> Enable/disable debug <tags> is a space/comma/column-
messages for the specified separated list of debug component
debug tags. names. Use -help-debug-tags to print
a list of debug component names that
you can use.
-debug-<tag> Enable/disable debug Use -help-debug-tags to print a list of
messages for the specified debug component names that you can
debug tag. use in <tag>.
-debug-no- Disable debug messages
<tag> for the specified debug tag.
-logcat Enable logcat output with If the environment variable
<logtags> given tags. ANDROID_LOG_TAGS is defined and
not empty, its value will be used to
enable logcat output by default.
-shell Create a root shell console You can use this command even if the
on the current terminal. adb daemon in the emulated system
is broken. Pressing Ctrl-c from the
shell stops the emulator instead of the
shell.
-shell-serial <d Enable the root shell (as <device> must be a QEMU device
evice> in -shell and specify the type. See the documentation for '-
QEMU character device to serial dev'
use for communication with at http://www.bellard.org/qemu/qemu-
the shell. doc.html#SEC10 for a list of device
types.
Here are some examples:
• -shell-serial stdio is identical to -
shell
• -shell-serial
tcp::4444,server,nowait lets you
communicate with the shell
over TCP port 4444
• -shell-serial fdpair:3:6 lets a
parent process communicate
with the shell using fds 3 (in)
and 6 (out)
• -shell-serial fdpair:0:1 uses the
normal stdin and stdout fds,
except that QEMU won't tty-
cook the data.
-show-kernel Display kernel messages.
<name>
-trace <name> Enable code profiling (press
F9 to start), written to a
specified file.
-verbose Enable verbose output. Equivalent to -debug-init.
You can define the default verbose
output options used by emulator
instances in the Android environment
variable ANDROID_VERBOSE. Define
the options you want to use in a
comma-delimited list, specifying only
the stem of each option: -debug-
<tags>.
Here's an example showing
ANDROID_VERBOSE defined with the -
debug-init and -debug-modem options
:
ANDROID_VERBOSE=init,modem
For more information about debug
tags, use <-help-debug-tags>.
Media -audio Use the specified audio
<backend> backend.
-audio-in Use the specified audio-
<backend> input backend.
-audio-out Use the specified audio-
<backend> output backend.
-noaudio Disable audio support in
the current emulator
instance.
-radio Redirect radio modem
<device> interface to a host
character device.
-useaudio Enable audio support in the Enabled by default.
current emulator instance.
Netwo -dns-server Use the specified DNS The value of <servers> must be a
rk <servers> server(s). comma-separated list of up to 4 DNS
server names or IP addresses.
-http-proxy Make all TCP connections The value of <proxy> can be one of
<proxy> through a specified the following:
HTTP/HTTPS proxy http://<server>:<port>
http://<username>:<password>@<se
rver>:<port>
The http:// prefix can be omitted. If
the -http-proxy <proxy>command is
not supplied, the emulator looks up
the http_proxyenvironment variable
and automatically uses any value
matching the<proxy> format
described above.
-netdelay Set network latency Default value is none. See the table
<delay> emulation to <delay>. in Network Delay Emulation for
supported <delay> values.
-netfast Shortcut for -netspeed full
-netdelay none
-netspeed Set network speed Default value is full. See the table
<speed> emulation to <speed>. in Network Speed Emulation for
supported <speed> values.
-port <port> Set the console port The console port number must be an
number for this emulator even integer between 5554 and 5584,
instance to <port>. inclusive. <port>+1 must also be free
and will be reserved for ADB.
-report-console Report the assigned <socket> must use one of these
<socket> console port for this formats:
emulator instance to a tcp:<port>[,server]
remote third party before [,max=<seconds>]
starting the emulation. unix:<port>[,server]
[,max=<seconds>]
Use -help-report-console
to view more information about this
topic.
Syste -cpu-delay Slow down emulated CPU Supported values for <delay> are
m <delay> speed by <delay> integers between 0 and 1000.
Note that the <delay> does not
correlate to clock speed or other
absolute metrics — it simply
represents an abstract, relative delay
factor applied non-deterministically in
the emulator. Effective performance
does not always scale in direct
relationship with <delay> values.
-gps <device> Redirect NMEA GPS to Use this command to emulate an
character device. NMEA-compatible GPS unit connected
to an external character device or
socket. The format of<device> must
be QEMU-specific serial device
specification. See the documentation
for 'serial -dev'
athttp://www.bellard.org/qemu/qemu-
doc.html#SEC10.
-nojni Disable JNI checks in the
Dalvik runtime.
-qemu Pass arguments to qemu.
-qemu -h Display qemu help.
-radio Redirect radio mode to the The format of <device> must be
<device> specified character device. QEMU-specific serial device
specification. See the documentation
for 'serial -dev'
athttp://www.bellard.org/qemu/qemu-
doc.html#SEC10.
-timezone Set the timezone for the <timezone> must be specified in
<timezone> emulated device to zoneinfo format. For example:
<timezone>, instead of the "America/Los_Angeles"
host's timezone. "Europe/Paris"
-version Display the emulator's
version number.
UI -dpi-device <dpi> Scale the resolution of the The default value is 165. See also -
emulator to match the scale.
screen size of a physical
device.
-no-boot-anim Disable the boot animation Disabling the boot animation can
during emulator startup. speed the startup time for the
emulator.
-no-window Disable the emulator's
graphical window display.
-scale <scale> Scale the emulator window. <scale> is a number between 0.1 and
3 that represents the desired scaling
factor. You can also specify scale as a
DPI value if you add the suffix "dpi" to
the scale value. A value of "auto" tells
the emulator to select the best
window size.
-raw-keys Disable Unicode keyboard
reverse-mapping.
-noskin Don't use any emulator
skin.
-keyset <file> Use the specified keyset The keyset file defines the list of key
file instead of the default. bindings between the emulator and
the host keyboard. For more
information, use -help-keyset to print
information about this topic.
-onion Use overlay image over No support for JPEG. Only PNG is
<image> screen. supported.
-onion-alpha Specify onion skin Default is 50.
<percent> translucency value (as
percent).
-onion-rotation Specify onion skin rotation. <position> must be one of the values
<position> 0, 1, 2, 3.
-skin <skinID> This emulator option is Please set skin options using AVDs,
deprecated. rather than by using this emulator
option. Using this option may yield
unexpected and in some cases
misleading results, since the density
with which to render the skin may not
be defined. AVDs let you associate
each skin with a default density and
override the default as needed. For
more information, see Android Virtual
Devices.
-skindir <dir> This emulator option is See comments for -skin, above.
deprecated.