Your shopping cart is empty!
An Android Virtual Device (AVD) is an emulator configuration that lets you model an actual device by defining hardware and software options to be emulated by the Android Emulator.
The easiest way to create an AVD is to use the graphical AVD Manager, which you launch from Eclipse by clicking Window > AVD Manager. You can also start the AVD Manager from the command line by calling the androidtool with the avdoptions, from the /tools/ directory.
You can also create AVDs on the command line by passing the androidtool options. For more information on how to create AVDs in this manner, see Managing Virtual Devices from the Command Line.
An AVD consists of:
You can create as many AVDs as you need, based on the types of device you want to model. To thoroughly test your application, you should create an AVD for each general device configuration (for example, different screen sizes and platform versions) with which your application is compatible and test your application on each one.
Keep these points in mind when you are selecting a system image target for your AVD:
The AVD Manager is an easy to use user interface to manage your AVD (Android Virtual Device) configurations. An AVD is a device configuration for the Android emulator that allows you to model different configurations of Android-powered devices. When you start the AVD Manager in Eclipse or run the androidtool on the command line, you will see the AVD Manager as shown in figure 1:
Figure 1. Screenshot of the AVD Manager.
From the main screen, you can create, delete, repair and start AVDs as well as see the details of each AVD.
You can create as many AVDs as you would like to test on. It is recommended that you test your applications on all API levels higher than the target API level for your application.
To create an AVD:
In the Virtual Devices panel, you'll see a list of existing AVDs. Click New to create a new AVD. The Create New AVD dialog appears.
Figure 2. Screenshot of the Create AVD window
Give it a name, a platform target, an SD card size, and a skin (HVGA is default). You can also add specific hardware features of the emulated device by clicking the New... button and selecting the feature. For a list of hardware features, see Hardware options.
Note: Be sure to define a target for your AVD that satisfies your application's Build Target (the AVD platform target must have an API Level equal to or greater than the API Level that your application compiles against).
Your AVD is now ready and you can either close the AVD Manager, create more AVDs, or launch an emulator with the AVD by selecting a device and clicking Start.
If you are creating a new AVD, you can specify the following hardware options for the AVD to emulate:
The androidtool lets you manage AVDs on the command line. For a complete reference of the command line options that you can use, see the reference for the android tool.
To generate a list of system image targets, use this command:
android list targets
The androidtool scans the /platforms/and /add-ons/directories looking for valid system images and then generates the list of targets. Here's an example of the command output:
Available Android targets:
id: 1 or "android-3"
Name: Android 1.5
API level: 3
Skins: QVGA-L, HVGA-L, HVGA (default), HVGA-P, QVGA-P
id: 2 or "android-4"
Name: Android 1.6
API level: 4
Skins: QVGA, HVGA (default), WVGA800, WVGA854
id: 3 or "android-7"
Name: Android 2.1-update1
API level: 7
Skins: QVGA, WQVGA400, HVGA (default), WVGA854, WQVGA432, WVGA800
id: 4 or "android-8"
Name: Android 2.2
API level: 8
Skins: WQVGA400, QVGA, WVGA854, HVGA (default), WVGA800, WQVGA432
id: 5 or "android-9"
Name: Android 2.3
API level: 9
Skins: HVGA (default), WVGA800, WQVGA432, QVGA, WVGA854, WQVGA400
In addition to creating AVDs with the AVD Manager user interface, you can also create them by passing in command line arguments to the androidtool.
Open a terminal window and change to the /tools/directory, if needed.
To create each AVD, you issue the command android create avd, with options that specify a name for the new AVD and the system image you want to run on the emulator when the AVD is invoked. You can specify other options on the command line also, such as the emulated SD card size, the emulator skin, or a custom location for the user data files.
android create avd
Here's the command-line usage for creating an AVD:
android create avd -n -t [-<option> ] ...
You can use any name you want for the AVD, but since you are likely to be creating multiple AVDs, you should choose a name that lets you recognize the general characteristics offered by the AVD. The target ID is an integer assigned by the androidtool. The target ID is not derived from the system image name, version, or API Level, or other attribute, so you need to run the android list targetscommand to list the target ID of each system image. You should do this before you run the android create avdcommand. See the android tool documentation for more information on the command line options.
android list targets
When you've selected the target you want to use and made a note of its ID, use the android create avdcommand to create the AVD, supplying the target ID as the -targument. Here's an example that creates an AVD with name "my_android1.5" and target ID "2" (the standard Android 1.5 system image in the list above):
android create avd -n my_android1.5 -t 2
If the target you selected was a standard Android system image ("Type: platform"), the androidtool next asks you whether you want to create a custom hardware profile.
Android 1.5 is a basic Android platform.
Do you wish to create a custom hardware profile [no]
If you want to set custom hardware emulation options for the AVD, enter "yes" and set values as needed. If you want to use the default hardware emulation options for the AVD, just press the return key (the default is "no"). The androidtool creates the AVD with name and system image mapping you requested, with the options you specified. For more information, see Setting Hardware Emulation Options.
Note: If you are creating an AVD whose target is an SDK add-on, the androidtool does not allow you to set hardware emulation options. It assumes that the provider of the add-on has set emulation options appropriately for the device that the add-on is modeling, and so prevents you from resetting the options.
When testing your application, we recommend that you test your application in several different AVDs, using different screen configurations (different combinations of size and density). In addition, you should set up the AVDs to run at a physical size that closely matches an actual device.
To set up your AVDs for a specific resolution or density, follow these steps:
android create avd -n -t --skin WVGA800
In the example above (WVGA medium density), the new AVD will emulate a 5.8" WVGA screen.
As an alternative to adjusting the emulator skin configuration, you can use the emulator skin's default density and add the -dpi-deviceoption to the emulator command line when starting the AVD. For example:
emulator -avd WVGA800 -scale 96dpi -dpi-device 160
When you create an AVD, the androidtool creates a dedicated directory for it on your development computer. The directory contains the AVD configuration file, the user data image and SD card image (if available), and any other files associated with the device. Note that the directory does not contain a system image — instead, the AVD configuration file contains a mapping to the system image, which it loads when the AVD is launched.
The androidtool also creates an .inifile for the AVD at the root of the .android/avd/directory on your computer. The file specifies the location of the AVD directory and always remains at the root the .android directory.
By default, the androidtool creates the AVD directory inside ~/.android/avd/(on Linux/Mac), C:\Documents and
Settings\\.android\on Windows XP, and C:\Users\\.android\on Windows 7 and Vista. If you want to use a custom location for the AVD directory, you can do so by using the -p option when you create the AVD:
android create avd -n my_android1.5 -t 2 -p path/to/my/avd
If the .android directory is hosted on a network drive, we recommend using the -poption to place the AVD directory in another location. The AVD's .ini file remains in the .android directory on the network drive, regardless of the location of the AVD directory.
If you want to move or rename an AVD, you can do so using this command:
android move avd -n [-<option> ] ...
If, for any reason, the platform/add-on root folder has its name changed (maybe because the user has installed an update of the platform/add-on) then the AVD will not be able to load the system image that it is mapped to. In this case, the android list targetscommand will produce this output:
The following Android Virtual Devices could not be loaded:
Error: Invalid value in image.sysdir. Run 'android update avd -n foo'
To fix this error, use the android update avdcommand to recompute the path to the system images.
android update avd
You can use the androidtool to delete an AVD. Here is the command usage:
android delete avd -n
When you issue the command, the androidtool looks for an AVD matching the specified name deletes the AVD's directory and files.
The Android SDK includes a virtual mobile device emulator that runs on your computer. The emulator lets you prototype, develop and test Android applications without using a physical device.
The Android emulator mimics all of the hardware and software features of a typical mobile device, except that it cannot place actual phone calls. It provides a variety of navigation and control keys, which you can "press" using your mouse or keyboard to generate events for your application. It also provides a screen in which your application is displayed, together with any other active Android applications.
To let you model and test your application more easily, the emulator utilizes Android Virtual Device (AVD) configurations. AVDs let you define certain hardware aspects of your emulated phone and allow you to create many configurations to test many Android platforms and hardware permutations. Once your application is running on the emulator, it can use the services of the Android platform to invoke other applications, access the network, play audio and video, store and retrieve data, notify the user, and render graphical transitions and themes.
The emulator also includes a variety of debug capabilities, such as a console from which you can log kernel output, simulate application interrupts (such as arriving SMS messages or phone calls), and simulate latency effects and dropouts on the data network.
The Android emulator is an application that provides a virtual 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 its behavior.
The Android system images available through the Android SDK Manager contain code for the Android Linux kernel, the native libraries, the Dalvik VM, and the various Android packages (such as the Android framework and preinstalled applications). The emulator provides dynamic binary translation of device machine code to the OS and processor architecture of your development machine.
The Android emulator supports many hardware features likely to be found on mobile devices, including:
The following sections describe the emulator and its use for development of Android applications in more detail.
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.
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 AVD Manager UI or the androidtool that is included in the SDK. For complete information about how to set up AVDs, see Managing Virtual Devices.
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 run it from within 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 redirection that allows 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, navigate to the tools/folder of the SDK. Enter emulatorcommand like this:
emulator -avd [<options>]
This initializes the emulator, loads an AVD configuration and displays the emulator window. For more information about command line options for the emulator, see the Android Emulator tool reference.
Note: You can run multiple instances of the emulator concurrently, each with its own AVD configuration and storage area for user data, SD card, and so on.
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.
For a reference of the emulator's startup commands and keyboard mapping, see the Android Emulator tool reference.
If you don't have access to Eclipse or the ADT Plugin, you can install your application on the emulator using the adb utility. Before installing the application, you need to build and package it into an .apkas described in Building and Running Apps. Once the application is installed, you can start the emulator from the command line as described previously, using any startup options necessary. When the emulator is running, you can also connect to the emulator instance's console to issue commands as needed.
As you update your code, you periodically package and install it on the emulator. The emulator preserves the application and its state data across restarts, in a user-data disk partition. To ensure that the application runs properly as you update it, you may need to delete the emulator's user-data partition. To do so, start the emulator with the -wipe-dataoption. For more information about the user-data partition and other emulator storage, see Working with Emulator Disk Images.
In order to make the Android emulator run faster and be more responsive, you can configure it to take advantage of hardware acceleration, using a combination of configuration options, specific Android system images and hardware drivers.
Caution: As of SDK Tools Revision 17, the graphics acceleration feature for the emulator is experimental; be alert for incompatibilities and errors when using this feature.
Graphics acceleration for the emulator takes advantage of your development computer's graphics hardware, specifically its graphics processing unit (GPU), to make screen drawing faster. To use the graphics acceleration feature, you must have the following versions of the Android development tools installed:
Use the Android SDK Manager to install these components:
Note: Not all applications are compatible with graphics hardware acceleration. In particular, the Browser application and applications using the WebViewcomponent are not compatible with graphics acceleration.
To configure an AVD to use graphics acceleration:
Note: You can also enable graphics acceleration when you start an emulator using command line options as describe in the next section.
Caution: Do not select the Snapshot: Enabled option. Snapshots are not supported for emulators with graphics acceleration enabled.
If you set GPU emulation to Yes for your AVD, then graphics acceleration is automatically enabled when you run it. If you did not enable GPU emulation when you created the AVD, you can still enable it at runtime.
To enable graphics acceleration at runtime for an AVD:
emulator -avd -gpu on
Note: You must specify an AVD configuration that uses Android 4.0.3 (API Level 15, revision 3) or higher system image target. Graphics acceleration is not available for earlier system images.
Caution: As of SDK Tools Revision 17, the virtual machine acceleration feature for the emulator is experimental; be alert for incompatibilities and errors when using this feature.
Many modern CPUs provide extensions for running virtual machines (VMs) more efficiently. Taking advantage of these extensions with the Android emulator requires some additional configuration of your development system, but can significantly improve the execution speed. Before attempting to use this type of acceleration, you should first determine if your development system’s CPU supports one of the following virtualization extensions technologies:
The specifications from the manufacturer of your CPU should indicate if it supports virtualization extensions. If your CPU does not support one of these virtualization technologies, then you cannot use virtual machine acceleration.
Note: Virtualization extensions are typically enabled through your computer's BIOS and are frequently turned off by default. Check the documentation for your system's motherboard to find out how to enable virtualization extensions.
Once you have determined that your CPU supports virtualization extensions, make sure you can work within these additional requirements of running an emulator inside an accelerated virtual machine:
To use virtual machine acceleration with the emulator, you need the following version of Android development tools. Use the Android SDK Manager to install these components:
If your development environment meets all of the requirements for running a VM-accelerated emulator, you can use the AVD Manager to create an x86-based AVD configuration:
Tip: System images are listed under each API Level in the SDK Manager. An x86 system image may not be available for all API levels.
Virtual machine acceleration for Windows requires the installation of the Intel Hardware Accelerated Execution Manager (Intel HAXM). The software requires an Intel CPU with Virtualization Technology (VT) support and one of the following operating systems:
To install the virtualization driver:
sc query intelhaxm