diff --git a/docs/html/images/tools/e-dpad.png b/docs/html/images/tools/e-dpad.png new file mode 100644 index 0000000000000..1fb9500d086d6 Binary files /dev/null and b/docs/html/images/tools/e-dpad.png differ diff --git a/docs/html/images/tools/e-emulator.png b/docs/html/images/tools/e-emulator.png new file mode 100644 index 0000000000000..4b758b9237f73 Binary files /dev/null and b/docs/html/images/tools/e-emulator.png differ diff --git a/docs/html/images/tools/e-iback.png b/docs/html/images/tools/e-iback.png new file mode 100644 index 0000000000000..ca9b984e7cff2 Binary files /dev/null and b/docs/html/images/tools/e-iback.png differ diff --git a/docs/html/images/tools/e-iclose.png b/docs/html/images/tools/e-iclose.png new file mode 100644 index 0000000000000..00ecfad7723c4 Binary files /dev/null and b/docs/html/images/tools/e-iclose.png differ diff --git a/docs/html/images/tools/e-ihome.png b/docs/html/images/tools/e-ihome.png new file mode 100644 index 0000000000000..a6ce33ef2b3e3 Binary files /dev/null and b/docs/html/images/tools/e-ihome.png differ diff --git a/docs/html/images/tools/e-ilocation.png b/docs/html/images/tools/e-ilocation.png new file mode 100644 index 0000000000000..2c152a686ecb0 Binary files /dev/null and b/docs/html/images/tools/e-ilocation.png differ diff --git a/docs/html/images/tools/e-iminimize.png b/docs/html/images/tools/e-iminimize.png new file mode 100644 index 0000000000000..66335396b195b Binary files /dev/null and b/docs/html/images/tools/e-iminimize.png differ diff --git a/docs/html/images/tools/e-imore.png b/docs/html/images/tools/e-imore.png new file mode 100644 index 0000000000000..dec890259bca1 Binary files /dev/null and b/docs/html/images/tools/e-imore.png differ diff --git a/docs/html/images/tools/e-ioverview.png b/docs/html/images/tools/e-ioverview.png new file mode 100644 index 0000000000000..828d2a56ebd0f Binary files /dev/null and b/docs/html/images/tools/e-ioverview.png differ diff --git a/docs/html/images/tools/e-ipower.png b/docs/html/images/tools/e-ipower.png new file mode 100644 index 0000000000000..e08a5bb7edfba Binary files /dev/null and b/docs/html/images/tools/e-ipower.png differ diff --git a/docs/html/images/tools/e-irotateleft.png b/docs/html/images/tools/e-irotateleft.png new file mode 100644 index 0000000000000..07d65f4d540b8 Binary files /dev/null and b/docs/html/images/tools/e-irotateleft.png differ diff --git a/docs/html/images/tools/e-irotateright.png b/docs/html/images/tools/e-irotateright.png new file mode 100644 index 0000000000000..939ff4e3ee650 Binary files /dev/null and b/docs/html/images/tools/e-irotateright.png differ diff --git a/docs/html/images/tools/e-irun.png b/docs/html/images/tools/e-irun.png new file mode 100644 index 0000000000000..7247db7e1e9e8 Binary files /dev/null and b/docs/html/images/tools/e-irun.png differ diff --git a/docs/html/images/tools/e-itakescreenshot.png b/docs/html/images/tools/e-itakescreenshot.png new file mode 100644 index 0000000000000..a38d7d91a3450 Binary files /dev/null and b/docs/html/images/tools/e-itakescreenshot.png differ diff --git a/docs/html/images/tools/e-ivolumedown.png b/docs/html/images/tools/e-ivolumedown.png new file mode 100644 index 0000000000000..ef4f3867faca1 Binary files /dev/null and b/docs/html/images/tools/e-ivolumedown.png differ diff --git a/docs/html/images/tools/e-ivolumeup.png b/docs/html/images/tools/e-ivolumeup.png new file mode 100644 index 0000000000000..61dff17539a40 Binary files /dev/null and b/docs/html/images/tools/e-ivolumeup.png differ diff --git a/docs/html/images/tools/e-izoom.png b/docs/html/images/tools/e-izoom.png new file mode 100644 index 0000000000000..4b702e8b2d18d Binary files /dev/null and b/docs/html/images/tools/e-izoom.png differ diff --git a/docs/html/images/tools/e-selectdeploymenttarget.png b/docs/html/images/tools/e-selectdeploymenttarget.png new file mode 100644 index 0000000000000..60c088b11cd62 Binary files /dev/null and b/docs/html/images/tools/e-selectdeploymenttarget.png differ diff --git a/docs/html/tools/devices/emulator.jd b/docs/html/tools/devices/emulator.jd index 5bdd4e2d4bf73..d9a38f7baa0a7 100644 --- a/docs/html/tools/devices/emulator.jd +++ b/docs/html/tools/devices/emulator.jd @@ -1,4 +1,7 @@ -page.title=Using the Emulator +page.title=Running Apps in the Android Emulator +parent.title=Android Studio +parent.link=index.html +page.tags=emulator @jd:body
@@ -6,1568 +9,650 @@ page.title=Using the Emulator

In this document

    -
  1. Overview
  2. -
  3. Android Virtual Devices and the Emulator
  4. -
  5. Starting and Stopping the Emulator
  6. -
  7. Installing Applications on the Emulator
  8. -
  9. Using Hardware Acceleration -
      -
    1. Configuring Graphics Acceleration
    2. -
    3. Configuring Virtual Machine Acceleration
    4. -
    -
  10. -
  11. SD Card Emulation -
      -
    1. Creating an SD card image
    2. -
    3. Copying files to an SD card image
    4. -
    5. Loading an SD card image
    6. -
    -
  12. -
  13. Working with Emulator Disk Images -
      -
    1. Default image files
    2. -
    3. Runtime images: user data and SD card
    4. -
    5. Temporary images
    6. -
    -
  14. -
  15. Emulator Networking -
      -
    1. Network Address Space
    2. -
    3. Local Networking Limitations
    4. -
    5. Using Network Redirection
    6. -
    7. Configuring the Emulator's DNS Settings
    8. -
    9. Using the Emulator with a Proxy
    10. -
    11. Interconnecting Emulator Instances
    12. -
    13. Sending a Voice Call or SMS to Another Emulator Instance
    14. -
    -
  16. -
  17. Using the Emulator Console -
      -
    1. Port Redirection
    2. -
    3. Geo Location Provider Emulation
    4. -
    5. Hardware Events Emulation
    6. -
    7. Device Power Characteristics
    8. -
    9. Network Status
    10. -
    11. Network Delay Emulation
    12. -
    13. Network Speed Emulation
    14. -
    15. Telephony Emulation
    16. -
    17. SMS Emulation
    18. -
    19. VM State
    20. -
    21. Emulator Window
    22. -
    23. Terminating an Emulator Instance
    24. -
    -
  18. -
  19. Emulator Limitations
  20. -
  21. Troubleshooting Emulator Problems
  22. +
  23. About the Android Emulator
  24. +
  25. Running an App in the Android Emulator
  26. +
  27. Launching the Android Emulator Without Running an App
  28. +
  29. Navigating on the Screen
  30. +
  31. Performing Basic Tasks in the Emulator
  32. +
  33. Working With Extended Controls, Settings, and Help
  34. +

See also

    -
  1. Android Emulator
  2. -
  3. Managing AVDs with AVD Manager
  4. +
  5. Android Emulator Command Line Features
  6. +
  7. Managing AVDs with + AVD Manager
+
-

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 simulates a device and displays it on your development +computer. It lets you prototype, develop, and test +Android apps without using a hardware device. The emulator supports Android +phone, tablet, Android Wear, and Android TV devices. It comes with predefined +device types +so you can get started quickly, and you can create your own device definitions +and emulator skins.

-

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.

+

The Android Emulator is fast, +powerful, and feature-rich. It can transfer information faster than using +a connected hardware device, speeding up the development process. The +multi-core feature lets the emulator take advantage of multiple core +processors on your development computer to improve emulator performance even +more.

- +emulator -

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 +

About the Android Emulator

+ +

You can launch an app on the emulator when you run your project, or you can +drag an APK file onto the emulator to install it. As with a hardware device, +after you install an app +on a virual device, it remains until you uninstall or replace it. If needed, you +can test how multiple apps, such as your own or system apps, work with each +other.

+ +

Features for trying out your apps

+ +

You interact with the emulator just as you would with a hardware device, but +using your mouse and keyboard, and emulator buttons and controls. +The emulator supports virtual hardware buttons and touchscreens, including +two-finger operations, +as well as directional pads (D-pads), trackballs, wheels, and various +sensors. You can dynamically resize the emulator window as needed, zoom in and +out, change the orientation, and even take a screenshot.

+ +

When your app 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.

+apps, access the network, play audio and video, accept audio input, +store and retrieve data, notify the user, and render graphical transitions and +themes. The emulator has controls that let +you easily send incoming phone calls and text messages, specify +the location of the device, simulate fingerprint scans, specify network +speed and status, and simulate battery properties. The emulator can +simulate an SD card and internal data storage; you can drag a file, such as a +graphics or data file, onto the emulator to store it.

-

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.

+

Android Virtual Device configurations

- - -

Overview

- -

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.

- - -

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.

+

The emulator uses an Android Virtual Device (AVD) configuration to determine +the look, functionality, and system image of the simulated device. AVDs let you +define certain hardware aspects of your emulated devices and allow you to create +many configurations to test different Android platforms and hardware +permutations.

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.

+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 android tool -that is included in the SDK. -For complete information about how to set up AVDs, see Managing Virtual Devices.

+

To create and manage AVDs, use the +AVD Manager. +For more information, see +Managing Virtual Devices.

+

Manifest settings

-

Starting and Stopping the Emulator

+

For your app to use certain emulator device features, you need to specify +in the manifest that your app will use them. For example, an Android Wear watch +requires the following <uses-feature> setting:

-

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 Android Studio -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 emulator command -like this:

- -
emulator -avd <avd_name> [<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.

- -

When you run your app from Android Studio, it installs and launches the -app on your connected device or emulator (launching the emulator, if necessary). -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 Android Studio, 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.

- - -

Installing Applications on the Emulator

- -

If you don't have access to Android Studio, 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 .apk as 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-data option. -For more information about the user-data partition and other emulator storage, -see Working with Emulator Disk Images.

- - -

Using Hardware Acceleration

- -

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.

- - -

Configuring Graphics Acceleration

- -

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 {@link -android.webkit.WebView} component are not compatible with graphics acceleration.

- -

To configure an AVD to use graphics acceleration:

- -
    -
  1. Make sure you have the required SDK components installed (listed above).
  2. -
  3. Start the AVD Manager and create a new AVD with the Target value of -Android 4.0.3 (API Level 15), revision 3 or higher.
  4. -
  5. If you want to have graphics acceleration enabled by default for this AVD, in the -Hardware section, click New, select GPU emulation -and set the value to Yes. -

    Note: You can also enable graphics acceleration when you -start an emulator using command line options as describe in the next section.

    -
  6. -
  7. Name the AVD instance and select any other configuration options. -

    Caution: Do not select the Snapshot: Enabled -option. Snapshots are not supported for emulators with graphics acceleration enabled.

    -
  8. -
  9. Click Create AVD to save the emulator configuration.
  10. -
- -

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:

- - - - -

Configuring Virtual Machine Acceleration

- -

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:

- -
    -
  1. In the Android SDK Manager, make sure you have an x86-based System Image - installed for your target Android version. If you do not have an x86 System - Image installed, select one in the Android SDK Manager and install it. -

    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.

    -
  2. -
  3. Start the AVD Manager and create a new AVD with an x86 value for the -CPU/ABI field. You may need to select a specific Target value, or -select a Target value and then select a specific CPU/ABI -option.
  4. -
  5. Name the emulator instance and select any other configuration options.
  6. -
  7. Click Create AVD to save the emulator configuration.
  8. -
- -

Configuring VM Acceleration on Windows

- -

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:

- -
    -
  1. Start the Android SDK Manager, select Extras and then select Intel -Hardware Accelerated Execution Manager.
  2. -
  3. After the download completes, execute {@code -<sdk>/extras/intel/Hardware_Accelerated_Execution_Manager/IntelHAXM.exe}.
  4. -
  5. Follow the on-screen instructions to complete installation.
  6. -
  7. After installation completes, confirm that the virtualization driver is operating correctly by -opening a command prompt window and running the following command: -
    sc query intelhaxm
    -

    You should see a status message including the following information:

    -SERVICE_NAME: intelhaxm
    -       ...
    -       STATE              : 4  RUNNING
    -       ...
    -
    -
  8. -
- -

To run an x86-based emulator with VM acceleration:

- - -

You can adjust the amount of memory available to the Intel HAXM kernel extension by re-running -its installer.

- -

You can stop using the virtualization driver by uninstalling it. Re-run the installer or use -the Control Panel to remove the software.

- - -

Configuring VM Acceleration on Mac

- -

Virtual machine acceleration on a Mac requires the installation of the Intel Hardware Accelerated -Execution Manager (Intel HAXM) kernel extension to allow the Android emulator to make use of CPU -virtualization extensions. The kernel extension is compatible with Mac OS X Snow Leopard (version -10.6.0) and higher.

- -

To install the Intel HAXM kernel extension:

- -
    -
  1. Start the Android SDK Manager, select Extras and then select Intel -Hardware Accelerated Execution Manager. -
  2. After the download completes, execute - {@code <sdk>/extras/intel/Hardware_Accelerated_Execution_Manager/IntelHAXM.dmg}.
  3. -
  4. Double click the IntelHAXM.mpkg icon to begin installation.
  5. -
  6. Follow the on-screen instructions to complete installation.
  7. -
  8. After installation completes, confirm that the new kernel extension is operating correctly by -opening a terminal window and running the following command: -
    kextstat | grep intel
    -

    You should see a status message containing the following extension name, indicating that the - kernel extension is loaded:

    -
    com.intel.kext.intelhaxm
    -
  9. -
- -

To run an x86-based emulator with VM acceleration:

- - -

You can adjust the amount of memory available to the Intel HAXM kernel extension by re-running -the installer.

- -

You can stop using the virtualization kernel driver by uninstalling it. Before removing it, shut -down any running x86 emulators. To unload the virtualization kernel driver, run the following -command in a terminal window:

- -
sudo /System/Library/Extensions/intelhaxm.kext/Contents/Resources/uninstall.sh
- -

Configuring VM Acceleration on Linux

- -

Linux-based systems support virtual machine acceleration through the KVM software package. Follow -instructions for installing KVM on your -Linux system, and verify that KVM is enabled. In addition to following the installation -instructions, be aware of these configuration requirements:

- - - -

To run an x86-based emulator with VM acceleration:

- - - -

Important: When using the {@code -qemu} command line option, make sure -it is the last parameter in your command. All subsequent options are interpreted as qemu-specific -parameters.

- - -

SD Card Emulation

- -

You can create a disk image and then load it to the emulator at startup, to -simulate the presence of a user's SD card in the device. To do this, you can specify -an SD card image when you create an AVD, or you can use the mksdcard utility included -in the SDK.

- -

The following sections describe how to create an SD card disk image, how to copy -files to it, and how to load it in the emulator at startup.

- -

Note that you can only load a disk image at emulator startup. Similarly, you -can not remove a simulated SD card from a running emulator. However, you can -browse, send files to, and copy/remove files from a simulated SD card either -with adb or the emulator.

- -

The emulator supports emulated SDHC cards, so you can create an SD card image -of any size up to 128 gigabytes.

- - -

Creating an SD card image

- -

There are several ways of creating an SD card image. The easiest way is to use the -AVD Manager to create a new SD card by specifying a size when you create an AVD. -You can also use the {@code android} command line tool when creating an AVD. Just add the --c option to your command:

- -
android create avd -n <avd_name> -t <targetID> -c <size>[K|M]
- -

The -c option can also be used to to specify a path to an SD card -image for the new AVD. For more information, see Managing Virtual Devices -from the Command Line. -

- -

You can also use the mksdcard tool, included in the SDK, to create a FAT32 disk -image that you can load in the emulator at startup. You can access mksdcard in -the tools/ directory of the SDK and create a disk image like this:

- -
mksdcard <size> <file>
- -

For example:

- -
mksdcard 1024M sdcard1.iso
- -

For more information, see mksdcard.

- - -

Copying files to an SD card image

- -

Once you have created the disk image, you can copy files to it prior to -loading it in the emulator. To copy files, you can mount the image as a loop -device and then copy the files to it, or you can use a utility such as {@code mtools} to -copy the files directly to the image. The {@code mtools} package is available for Linux, -Mac, and Windows.

- -

Alternatively, you can use the {@code adb push} command to move files onto an SD card image -while it is loaded in an emulator. For more information see the {@code adb push} documentation.

- -

Loading an SD card image

- -

By default, the emulator loads the SD card image that is stored with the active -AVD (see the -avd startup option).

- -

Alternatively, you can start the emulator with the --sdcard flag and specify the name and path of your image (relative -to the current working directory):

- -
emulator -sdcard <filepath>
- - -

Working with Emulator Disk Images

- -

The emulator uses mountable disk images stored on your development machine to -simulate flash (or similar) partitions on an actual device. For example, it uses a -disk image containing an emulator-specific kernel, the Android system, a -ramdisk image, and writeable images for user data and simulated SD card.

- -

To run properly, the emulator requires access to a specific set of disk image -files. By default, the Emulator always looks for the disk images in the -private storage area of the AVD in use. If no images exist there when -the Emulator is launched, it creates the images in the AVD directory based on -default versions stored in the SDK.

- -

Note: The default storage location for -AVDs is in ~/.android/avd on OS X and Linux, C:\Documents and -Settings\<user>\.android\ on Windows XP, and -C:\Users\<user>\.android\ -on Windows Vista.

- -

To let you use alternate or custom versions of the image files, the emulator -provides startup options that override the default locations and filenames of -the image files. When you use one of these options, the emulator searches for the image -file under the image name or location that you specify; if it can not locate the -image, it reverts to using the default names and location.

- -

The emulator uses three types of image files: default image files, runtime -image files, and temporary image files. The sections below describe how to -override the location/name of each type of file.

- -

Default image files

- -

When the emulator launches, but does not find an existing user data image in -the active AVD's storage area, it creates a new one from a default version -included in the SDK. The default user data image is read-only. The image -files are read-only.

- -

The emulator provides the -system <dir> startup option to -let you override the location where the emulator looks for the default -user data image.

- -

The emulator also provides a startup option that lets you override the name -of the default user data image, as described in the following table. When you use the -option, the emulator looks in the default directory, or in a custom location -(if you specified -system <dir>).

- - - - - - - - - - - - - - - - -
NameDescriptionComments
userdata.imgThe initial user-data disk imageOverride using -initdata <file>. Also see --data <file>, below.
- -

Runtime images: user data and SD card

- -

At runtime, the emulator reads and writes data to two disk images: a -user-data image and (optionally) an SD card image. These images emulate the user-data -partition and removable storage media on actual device.

- -

The emulator provides a default user-data disk image. At startup, the emulator -creates the default image as a copy of the system user-data image (user-data.img), -described above. The emulator stores the new image with the files of the active AVD.

- - - -

The emulator provides startup options to let you override the actual names and storage -locations of the runtime images to load, as described in the following table. When you use one -of these options, the emulator looks for the specified file(s) in the current working directory, -in the AVD directory, or in a custom location (if you specified a path with the filename).

- - - - - - - - - - - - - - - - - - - -
NameDescriptionComments
userdata-qemu.imgAn image to which the emulator writes runtime user-data for a unique user.Override using -data <filepath>, where <filepath> is the -path the image, relative to the current working directory. If you supply a filename only, -the emulator looks for the file in the current working directory. If the file at <filepath> does -not exist, the emulator creates an image from the default userdata.img, stores it under the name you -specified, and persists user data to it at shutdown.
sdcard.imgAn image representing an SD card inserted into the emulated device.Override using -sdcard <filepath>, where <filepath> is the -path the image, relative to the current working directory. If you supply a filename only, -the emulator looks for the file in the current working directory.
- -

User-Data Image

- -

Each emulator instance uses a writeable user-data image to store user- and -session-specific data. For example, it uses the image to store a unique user's -installed application data, settings, databases, and files.

- -

At startup, the emulator attempts to load a user-data image stored during -a previous session. It looks for the file in the current working directory, -in the AVD directory described in a previous section and at the custom location/name -that you specified at startup.

- - - -

Note: Because of the AVD configurations used in the emulator, -each emulator instance gets its own dedicated storage. There is no longer a need -to use the -d option to specify an instance-specific storage area.

- -

SD Card

- -

Optionally, you can create a writeable disk image that the emulator can use -to simulate removeable storage in an actual device. For information about how to create an -emulated SD card and load it in the emulator, see SD Card Emulation

- -

You can also use the android tool to automatically create an SD Card image -for you, when creating an AVD. For more information, see Managing Virtual Devices with AVD -Manager. - - -

Temporary Images

- -

The emulator creates two writeable images at startup that it deletes at -device power-off. The images are:

- - - -

The emulator does not permit renaming the temporary system image or -persisting it at device power-off.

- -

The /cache partition image is initially empty, and is used by -the browser to cache downloaded web pages and images. The emulator provides an --cache <file>, which specifies the name of the file in which -to persist the /cache image at device power-off. If <file> - does not exist, the emulator creates it as an empty file.

- -

You can also disable the use of the cache partition by specifying the --nocache option at startup.

- - -

Emulator Networking

- -

The emulator provides versatile networking capabilities that you can use to -set up complex modeling and testing environments for your application. The -sections below introduce the emulator's network architecture and capabilities. -

- -

Network Address Space

- -

Each instance of the emulator runs behind a virtual router/firewall service -that isolates it from your development machine's network interfaces and settings -and from the internet. An emulated device can not see your development machine -or other emulator instances on the network. Instead, it sees only that it is -connected through Ethernet to a router/firewall.

- -

The virtual router for each instance manages the 10.0.2/24 network address -space — all addresses managed by the router are in the form of -10.0.2.<xx>, where <xx> is a number. Addresses within this space are -pre-allocated by the emulator/router as follows:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Network AddressDescription
10.0.2.1Router/gateway address
10.0.2.2Special alias to your host loopback interface (i.e., 127.0.0.1 on your -development machine)
10.0.2.3First DNS server
10.0.2.4 / 10.0.2.5 / 10.0.2.6Optional second, third and fourth DNS server (if any)
10.0.2.15The emulated device's own network/ethernet interface
127.0.0.1The emulated device's own loopback interface
- -

Note that the same address assignments are used by all running emulator -instances. That means that if you have two instances running concurrently on -your machine, each will have its own router and, behind that, each will have an -IP address of 10.0.2.15. The instances are isolated by a router and can -not see each other on the same network. For information about how to -let emulator instances communicate over TCP/UDP, see Connecting Emulator Instances.

- -

Also note that the address 127.0.0.1 on your development machine corresponds -to the emulator's own loopback interface. If you want to access services running -on your development machine's loopback interface (a.k.a. 127.0.0.1 on your -machine), you should use the special address 10.0.2.2 instead.

- -

Finally, note that each emulated device's pre-allocated addresses are -specific to the Android emulator and will probably be very different on real -devices (which are also very likely to be NAT-ed, i.e., behind a -router/firewall)

- - -

Local Networking Limitations

- -

Android applications running in an emulator can connect to the network available on your -workstation. However, they connect through the emulator, not directly to hardware, and the emulator -acts like a normal application on your workstation. This means that the emulator, and thus your -Android applications, are subject to some limitations:

- - - -

The emulator's virtual router should be able to handle all outbound TCP and -UDP connections/messages on behalf of the emulated device, provided your -development machine's network environment allows it to do so. There are no -built-in limitations on port numbers or ranges except the one imposed by your -host operating system and network.

- -

Depending on the environment, the emulator may not be able to support other -protocols (such as ICMP, used for "ping") might not be supported. Currently, the -emulator does not support IGMP or multicast.

- -

Using Network Redirection

- -

To communicate with an emulator instance behind its virtual router, you need -to set up network redirection on the virtual router. Clients can then connect -to a specified guest port on the router, while the router directs traffic -to/from that port to the emulated device's host port.

- -

To set up the network redirection, you create a mapping of host and guest -ports/addresses on the emulator instance. There are two ways to set up -network redirection: using emulator console commands and using the ADB tool, as -described below.

- - -

Setting up Redirection through the Emulator Console

- -

Each emulator instance provides a control console the you can connect to, to -issue commands that are specific to that instance. You can use the -redir console command to set up redirection as needed for an -emulator instance.

- -

First, determine the console port number for the target emulator instance. -For example, the console port number for the first emulator instance launched is -5554. Next, connect to the console of the target emulator instance, specifying -its console port number, as follows:

- -
telnet localhost 5554
- -

Once connected, use the redir command to work with redirection. -To add a redirection, use:

- -
add <protocol>:<host-port>:<guest-port>
+<uses-feature android:name="android.hardware.type.watch" />
 
-

where <protocol> is either tcp or udp, -and <host-port> and <guest-port> sets the -mapping between your own machine and the emulated system, respectively.

- -

For example, the following command sets up a redirection that handles all -incoming TCP connections to your host (development) machine on 127.0.0.1:5000 -and will pass them through to the emulated system's 10.0.2.15:6000.:

- -
redir add tcp:5000:6000
- -

To delete a redirection, you can use the redir del command. To -list all redirection for a specific instance, you can use redir -list. For more information about these and other console commands, see -Using the Emulator Console.

- -

Note that port numbers are restricted by your local environment. this typically -means that you cannot use host port numbers under 1024 without special -administrator privileges. Also, you won't be able to set up a redirection for a -host port that is already in use by another process on your machine. In that -case, redir generates an error message to that effect.

- -

Setting Up Redirection through ADB

- -

The Android Debug Bridge (ADB) tool provides port forwarding, an alternate -way for you to set up network redirection. For more information, see Forwarding Ports in the ADB -documentation.

- -

Note that ADB does not currently offer any way to remove a redirection, -except by killing the ADB server.

- - -

Configuring the Emulator's DNS Settings

- -

At startup, the emulator reads the list of DNS servers that your system is -currently using. It then stores the IP addresses of up to four servers on this -list and sets up aliases to them on the emulated addresses 10.0.2.3, 10.0.2.4, -10.0.2.5 and 10.0.2.6 as needed.

- -

On Linux and OS X, the emulator obtains the DNS server addresses by parsing -the file /etc/resolv.conf. On Windows, the emulator obtains the -addresses by calling the GetNetworkParams() API. Note that this -usually means that the emulator ignores the content of your "hosts" file -(/etc/hosts on Linux/OS X, %WINDOWS%/system32/HOSTS - on Windows).

- -

When starting the emulator at the command line, you can also use the --dns-server <serverList> option to manually specify the -addresses of DNS servers to use, where <serverList> is a comma-separated -list of server names or IP addresses. You might find this option useful if you -encounter DNS resolution problems in the emulated network (for example, an -"Unknown Host error" message that appears when using the web browser).

- - -

Using the Emulator with a Proxy

- -

If your emulator must access the Internet through a proxy server, you can use -the -http-proxy <proxy> option when starting the emulator, to -set up the appropriate redirection. In this case, you specify proxy information -in <proxy> in one of these formats:

- -
http://<machineName>:<port>
- -

or

- -
http://<username>:<password>@<machineName>:<port>
- -

The -http-proxy option forces the emulator to use the specified -HTTP/HTTPS proxy for all outgoing TCP connections. Redirection for UDP is not -currently supported.

- -

Alternatively, you can define the environment variable -http_proxy to the value you want to use for -<proxy>. In this case, you do not need to specify a value for -<proxy> in the -http-proxy command — the -emulator checks the value of the http_proxy environment variable at -startup and uses its value automatically, if defined.

- -

You can use the -verbose-proxy option to diagnose proxy -connection problems.

- - -

Interconnecting Emulator Instances

- -

To allow one emulator instance to communicate with another, you must set up -the necessary network redirection as illustrated below.

- -

Assume that your environment is

- - - -

and you want to run a server on B, to which C will connect, here is how you -could set it up:

- -
    -
  1. Set up the server on B, listening to -10.0.2.15:<serverPort>
  2. -
  3. On B's console, set up a redirection from -A:localhost:<localPort> to -B:10.0.2.15:<serverPort>
  4. -
  5. On C, have the client connect to 10.0.2.2:<localPort>
  6. -
- -

For example, if you wanted to run an HTTP server, you can select -<serverPort> as 80 and <localPort> as -8080:

- - - -

Sending a Voice Call or SMS to Another Emulator Instance

- -

The emulator automatically forwards simulated voice calls and SMS messages from one instance to -another. To send a voice call or SMS, use the dialer application or SMS application, respectively, -from one of the emulators.

- -

To initiate a simulated voice call to another emulator instance:

-
    -
  1. Launch the dialer application on the originating emulator instance.
  2. -
  3. As the number to dial, enter the console port number of the instance you'd like to call. You can determine - the console port number of the target instance by checking its window title, where the - console port number is reported as "Android Emulator (<port>).
  4. -
  5. Press "Dial". A new inbound call appears in the target emulator instance.
  6. -
- -

To send an SMS message to another emulator instance, launch the SMS application (if available). Specify the console port number of the target emulator instance as as the SMS address, enter the message text, and send the message. The message is delivered to the target emulator instance.

- -

You can also connect to an emulator instance's console to simulate an incoming voice call or SMS. For more information, see Telephony Emulation and SMS Emulation. - - -

Using the Emulator Console

- -

Each running emulator instance provides a console that lets you query and control the emulated -device environment. For example, you can use the console to manage port redirection, network -characteristics, and telephony events while your application is running on the emulator. To -access the console and enter commands, use telnet to connect to the console's port number.

- -

To connect to the console of any running emulator instance at any time, use this command:

- -
telnet localhost <console-port>
- -

An emulator instance occupies a pair of adjacent ports: a console port and an {@code adb} port. -The port numbers differ by 1, with the {@code adb} port having the higher port number. The console -of the first emulator instance running on a given machine uses console port 5554 and {@code adb} -port 5555. Subsequent instances use port numbers increasing by two — for example, 5556/5557, -5558/5559, and so on. Up to 16 concurrent emulator instances can run a console facility.

- -

To connect to the emulator console, you must specify a valid console port. If multiple emulator instances are running, you need to determine the console port of the emulator instance you want to connect to. You can find the instance's console port listed in the title of the instance window. For example, here's the window title for an instance whose console port is 5554:

- -

Android Emulator (5554)

- -

Alternatively, you can use the adb devices command, which prints a list of running emulator instances and their console port numbers. For more information, see Querying for Emulator/Device Instances in the adb documentation.

- -

Note: The emulator listens for connections on ports 5554-5587 and accepts connections only from localhost.

- -

Once you are connected to the console, you can then enter help [command] to see a list of console commands and learn about specific commands.

- -

To exit the console session, use quit or exit.

- -

The following sections below describe the major functional areas of the console.

- - -

Port Redirection

- -

You can use the console to add and remove port redirection while the emulator is running. After -you connect to the console, manage port redirection by entering the following command:

- -
redir <list|add|del> 
- -

The redir command supports the subcommands listed in the table below.

- - - - - - - - - - - - - - - - - - - - - - - - -
Subcommand - DescriptionComments
listList the current port redirection. 
add <protocol>:<host-port>:<guest-port>Add a new port redirection.
  • <protocol> must be either "tcp" or "udp"
  • -
  • <host-port> is the port number to open on the host
  • -
  • <guest-port> is the port number to route data to on the emulator/device
  • -
del <protocol>:<host-port>Delete a port redirection.The meanings of <protocol> and <host-port> are listed in the previous row.
- - -

Geo Location Provider Emulation

- -

You can use the console to set the geographic location reported to the applications running -inside an emulator. Use the geo command to send a simple GPS fix to the -emulator, with or without NMEA 1083 formatting:

- -
geo <fix|nmea>
- -

The geo command supports the subcommands listed in the table below.

- - - - - - - - - - - - - - - - - - -
SubcommandDescriptionComments
fix <longitude> <latitude> [<altitude>]Send a simple GPS fix to the emulator instance.Specify longitude and latitude in decimal degrees. Specify altitude in meters.
nmea <sentence>Send an NMEA 0183 sentence to the emulated device, as if it were sent from an emulated GPS modem.<sentence> must begin with '$GP'. Only '$GPGGA' and '$GPRCM' sentences are currently supported.
- -

You can issue the geo command as soon as an emulator instance is running. The -emulator sets the location you enter by creating a mock location provider. This provider responds to -location listeners set by applications, and also supplies the location to the {@link -android.location.LocationManager}. Any application can query the location manager to obtain the -current GPS fix for the emulated device by calling: - -

LocationManager.getLastKnownLocation("gps")
- -

For more information about the Location Manager, see {@link android.location.LocationManager}. +

There are also settings for camera, location, audio, microphone, phone, +networking, TV, touchscreen, and more. For more information, see + +<uses-feature>.

+ +

System images

+ +

The Android Emulator runs a full +Android system stack, down to the kernel level, that includes a set of +preinstalled apps (such as the dialer) that you can access from your +apps. You can choose which version of the Android system you want to +run in the emulator when creating AVDs.

-

Hardware Events Emulation

+

The Android system images available through the AVD Manager contain +code for the Android Linux kernel, the native libraries, the VM, and the +various Android packages (such as the Android framework and preinstalled +apps).

-

The {@code event} console commands sends hardware events to the emulator. The syntax for this -command is as follows:

- -
event <send|types|codes|text>
- -

The event command supports the subcommands listed in the table below.

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Subcommand - DescriptionComments
send <type>:<code>:<value> [...]Send one or more events to the Android kernel. You can use text names or integers for <type> and <value>.
typesList all <type> string aliases supported by the event subcommands. 
codes <type>List all <codes> string aliases supported by the event - subcommands for the specified <type>. 
event text <message>Simulate keypresses to send the specified string of characters as a message,The message must be a UTF-8 string. Unicode posts will be reverse-mapped according to the current device keyboard. Unsupported characters will be discarded silently.
- - -

Device Power Characteristics

- -

The {@code power} command controls the power state reported by the emulator to applications. The -syntax for this command is as follows:

- -
power <display|ac|status|present|health|capacity>
- -

The event command supports the subcommands listed in the table below.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Subcommand DescriptionComments
displayDisplay battery and charger state. 
ac <on|off>Set AC charging state to on or off.  
status <unknown|charging|discharging|not-charging|full>Change battery status as specified. 
present <true|false>Set battery presence state. 
health <unknown|good|overheat|dead|overvoltage|failure>Set battery health state. 
capacity <percent>Set remaining battery capacity state (0-100). 
- - -

Network Status

- -

You can use the console to check the network status and current delay and speed characteristics. To do so, connect to the console and use the netstatus command. Here's an example of the command and its output.

- -
network status
-
- - -

Network Delay Emulation

- -

The emulator lets you simulate various network latency levels, so that you can test your -application in an environment more typical of the actual conditions in which it will run. You can -set a latency level or range at emulator startup or you can use the console to change the latency, -while the application is running in the emulator.

- -

To set latency at emulator startup, use the -netdelay emulator option with a -supported <delay> value, as listed in the table below. Here are some -examples:

- -
emulator -netdelay gprs
-emulator -netdelay 40 100
- -

To make changes to network delay while the emulator is running, connect to the console and use -the netdelay command with a supported <delay> value from the table -below.

- -
network delay gprs
- -

The format of network <delay> is one of the following (numbers are milliseconds):

- - - - - - - - - - - - - - - - - - - - - - - -
ValueDescriptionComments
gprsGPRS(min 150, max 550)
edgeEDGE/EGPRS(min 80, max 400)
umtsUMTS/3G(min 35, max 200)
noneNo latency(min 0, max 0)
<num>Emulate an exact latency (milliseconds). 
<min>:<max>Emulate an specified latency range (min, max milliseconds). 
- - -

Network Speed Emulation

- -

The emulator also lets you simulate various network transfer rates. -You can set a transfer rate or range at emulator startup or you can use the console to change the -rate, while the application is running in the emulator.

- -

To set the network speed at emulator startup, use the -netspeed emulator option with a supported -<speed> value, as listed in the table below. Here are some examples:

- -
emulator -netspeed gsm
-emulator -netspeed 14.4 80
- -

To make changes to network speed while the emulator is running, connect to the console and use -the netspeed command with a supported <speed> value from the table -below.

- -
network speed 14.4 80
- -

The format of network <speed> is one of the following (numbers are -kilobits/sec):

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ValueDescriptionComments
gsmGSM/CSD(Up: 14.4, down: 14.4)
hscsdHSCSD(Up: 14.4, down: 43.2)
gprsGPRS(Up: 40.0, down: 80.0)
edgeEDGE/EGPRS(Up: 118.4, down: 236.8)
umtsUMTS/3G(Up: 128.0, down: 1920.0)
hsdpaHSDPA(Up: 348.0, down: 14400.0)
fullno limit(Up: 0.0, down: 0.0)
<num>Set an exact rate used for both upload and download.
<up>:<down>Set exact rates for upload and download separately.
- - -

Telephony Emulation

- -

The Android emulator includes its own GSM emulated modem that lets you simulate telephony -functions in the emulator. For example, you can simulate inbound phone calls, establish data -connections and terminate them. The Android system handles simulated calls exactly as it would -actual calls. The emulator does not support call audio.

- -

You can use the {@code gsm} command to access the emulator's telephony functions after connecting -to the console. The syntax for this command is as follows:

- -
gsm <call|accept|busy|cancel|data|hold|list|voice|status> 
- -

The gsm command supports the subcommands listed in the table below.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Subcommand DescriptionComments
call <phonenumber>Simulate an inbound phone call from <phonenumber>. 
accept <phonenumber>Accept an inbound call from <phonenumber> and change the call's state "active".You can change a call's state to "active" only if its current state is "waiting" or "held".
busy <phonenumber>Close an outbound call to <phonenumber> and change the call's state to "busy".You can change a call's state to "busy" only if its current state is "waiting".
cancel <phonenumber>Terminate an inbound or outbound phone call to/from <phonenumber>. 
data <state>Change the state of the GPRS data connection to <state>.Supported <state> values are:
+

Dependencies and prerequisites

+

The Android Emulator has the following requirements:

    -
  • unregistered -- No network available
  • -
  • home -- On local network, non-roaming
  • -
  • roaming -- On roaming network
  • -
  • searching -- Searching networks
  • -
  • denied -- Emergency calls only
  • -
  • off -- Same as 'unregistered'
  • -
  • on -- same as 'home'
  • -
-
holdChange the state of a call to "held". You can change a call's state to "held" only if its current state is "active" or "waiting".
listList all inbound and outbound calls and their states. 
voice <state>Change the state of the GPRS voice connection to <state>.Supported <state> values are:
-
    -
  • unregistered -- No network available
  • -
  • home -- On local network, non-roaming
  • -
  • roaming -- On roaming network
  • -
  • searching -- Searching networks
  • -
  • denied -- Emergency calls only
  • -
  • off -- Same as 'unregistered'
  • -
  • on -- Same as 'home'
  • -
-
statusReport the current GSM voice/data state.Values are those described for the voice and data commands.
- - -

SMS Emulation

- -

The Android emulator console lets you generate an SMS message and direct it to an emulator -instance. Once you connect to an emulator instance, you can generate an emulated incoming SMS using -the following command:

- -
sms send <senderPhoneNumber> <textmessage>
- -

where <senderPhoneNumber> contains an arbitrary numeric string.

- -

The console forwards the SMS message to the Android framework, which passes it through to an application that handles that message type.

- - -

VM State

- -

You can use the vm command to control the VM on an emulator instance. The syntax for -this command is as follows:

- -
vm <start|stop|status>
- -

The vm command supports the subcommands listed in the table below.

- - - - - - - - - - - - - - - - - - - - - - -
SubcommandDescriptionComments
startStart the VM on the instance.  
stopStop the VM on the instance.  
startDisplay the current status of the VM (running or stopped).  
- - -

Emulator Window

- -

You can use the window command to manage the emulator window. The syntax for this -command is as follows:

- -
window <scale>
- -

The vm command supports the subcommands listed in the table below.

- - - - - - - - - - - - -
SubcommandDescriptionComments
scale <scale>Scale the emulator window.A number between 0.1 and 3 that sets the 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.
- - -

Terminating an Emulator Instance

- -

You can terminate an emulator instance through the console, using the kill command.

- - -

Emulator Limitations

- -

The functional limitations of the emulator include:

- +

What's not supported

+ +

The Android Emulator supports most features of a device, but doesn't +include virtual hardware for:

+ +

The watch emulator for Android Wear doesn't support the Overview +(Recent Apps) button, D-pad, and fingerprint sensor.

+ +

While most end users of phones and tablets tend to use earlier API levels, +Android Wear and Android TV users tend to use the latest releases. Using recent +releases can give you a better experience using the emulator. +

+ +

Running an App in the Android Emulator

+ +

You can run an app from an Android Studio project. Or, you can run an app +that's been installed on the emulator as you would run any app on a device.

+ +

To start the emulator and run an app in your project:

+
    +
  1. Open an Android Studio project and select Run Run icon.
  2. +

    The Select Deployment Target dialog appears.

    +Select Deployment Target dialog +
  3. If you receive an error or warning message at the top of the dialog, click +the link to correct the problem or get more information.
  4. +

    The No USB devices or running emulators detected warning +means that you don’t currently have any emulators running, or any detected +hardware devices connected to your computer. If you +don’t have hardware devices connected to your computer, or any emulators +running, you can ignore it.

    +

    Some errors you must fix before you can continue, such as certain Hardware +Accelerated Execution Manager (Intel® HAXM) errors.

    +
  5. In the Select Deployment Target dialog, select an existing emulator +definition, and then click OK.

    +

    If you don’t see a definition you want to use, click Create New +Emulator to launch the AVD Manager. After you define a new AVD, in +the Select Deployment +Target dialog, click OK.

    +

    If you want to use this emulator definition as the default for your project, +select Use same selection for future launches.

    +

    The emulator launches and displays your app.

    +
  6. Test your app in the emulator.
  7. +

    You can use the features described in the following sections:

    + +
  8. To close the emulator, click Close Close icon.
  9. +

    The emulator device stores the installed app so you can run it again, if + needed. You need to uninstall an app to remove it. If you run the project + again on the same emulator, it replaces the app with the new version.

    +
+ +

Launching the Android Emulator Without Running an App

+ +

To start the emulator:

+
    +
  1. Open the AVD Manager.
  2. +
  3. Double-click an AVD, or click Run Run icon.
  4. +

    The Android Emulator appears.

    +

    While the emulator is running, you can run Android Studio projects and + choose the + emulator as the target device. You can also drag one or more APKs onto the + emulator to install them, and then run them.

    +
+ + + + +

Use your computer mouse pointer to mimic your finger on the touchscreen; +select menu items and input fields; and click buttons and controls. +Use your computer keyboard to type characters and enter emulator shortcuts.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureDescription
Swipe the screenPoint to the screen, press and hold the primary mouse button, swipe + across the screen, and then release.
Drag an itemPoint to an item on the screen, press and hold the primary mouse + button, move the item, and then release.
Tap
(touch)
Point to the screen, press the primary mouse button, and then release. + For example, you could click a text field to start typing in it, select an + app, or press a button.
Double tapPoint to the screen, press the primary mouse button quickly twice, + and then release.
Touch and holdPoint to an item on the screen, press the primary mouse button, hold, + and then release. For example, you could open options for an item.
TypeYou can type in the emulator by using your computer keyboard, or using + a keyboard that pops up on the emulator screen. For example, you could + type in a text field after you selected it.
Pinch and spread
Pressing Alt or Option (⌥) brings up a pinch gesture multi-touch + interface. The mouse acts as the first finger, and across the anchor point + is the second finger. Drag the cursor to move the first point.
+
Clicking the left mouse button acts like touching down both points, and + releasing acts like picking both up.
+ +

Performing Basic Tasks in the Emulator

+ +

The panel on the right side of the emulator lets you perform various tasks. +You can also drag files onto the emulator to install apps and download files. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureDescriptionKeyboard Shortcut
Close
Close icon
Close the emulator.
Minimize
Minimize icon
Minimize the emulator window.
ResizeResize the emulator as you would any other operating system window. The +emulator maintains an aspect ratio appropriate for your device.⌘↑ and ⌘↓
Power
Power icon
Click to turn the screen on or off.
Click and hold to turn the device + on or off.
Ctrl+P
⌘P
Volume Up
Volume Up icon
Click to view a slider control and turn the volume up. Click again to + turn it up more, or use the slider control to change the volume.
Ctrl+=
⌘=
Volume Down
Volume Down icon
Click to view a slider control and turn the volume down. Click again to + turn it down more, or use the slider control to change the volume.
Ctrl+-
⌘-
Rotate Left
Rotate Left icon
Rotate the phone 90 degrees counterclockwise.
Ctrl+Left
⌘←
Rotate Right
Rotate Right icon
Rotate the phone 90 degrees clockwise.
Ctrl+Right
⌘→
Take Screenshot
Take Screenshot icon +
Click to take a screenshot of the device. The default save location is + your computer desktop. To change the save location, select + > Settings. The emulator creates a + file with the name Screenshot_yyyymmdd-hhmmss.png + using the year, month, day, hour, minute, and second of the capture, for + example, Screenshot_20160219-145848.png.
Ctrl+S
⌘S
Enter Zoom Mode
Enter Zoom Mode icon +

Click so the cursor changes to the zoom icon:

+
    +
  • Left-click the screen to zoom in by 25%, up to a maximum of about twice + the screen resolution of the virtual device. +
  • Right-click to zoom out. +
  • Left-click and drag to select a box-shaped area to zoom in on. +
  • Right-click and drag a selection box to reset to default zoom. +
  • Ctrl-click to touch the screen while in zoom mode. +
+

Click Enter Zoom Mode again to return to normal screen size.

Ctrl+Z
⌘Z
+
While in zoom mode:
+
Ctrl+Up
Ctrl+Down
+
Ctrl+Shift+Up
Ctrl+Shift+Down
+
Ctrl+Shift+Left
Ctrl+Shift+Right
+
⌘↑ and ⌘↓
+
⇧⌘↑ and ⇧⌘↓
+
⇧⌘← and ⇧⌘→
Back
Back icon
Return to the previous screen, or close a dialog box, an options menu, + the Notifications panel, or the onscreen keyboard.
Ctrl+Backspace
+
⌘⌫
Home
Home icon
Return to the Home screen. Press and hold to open the item specific to + your API level.
Ctrl+H
⌘⇧H
Overview
Overview icon
+
(Recent Apps)
Tap to open a list of thumbnail images of apps you’ve worked with + recently. To open an app, tap it. To remove a thumbnail from the list, + swipe it left or right. This button isn't supported for Android Wear.
Ctrl+O
⌘O
MenuType the keyboard shortcut to simulate the Menu button, for example, + to open the menu for the selected app.
Ctrl+M
⌘M
More
More icon
Click to access other features and settings, described in the next + table.
Install an APKDrag an APK file onto the emulator screen. An APK Installer dialog + appears. When the installation completes, you can view the app in your + apps list.The app didn’t install if a dialog appears that says “APK failed + to install.”
Add a fileDrag any file onto the emulator screen. It’s placed in the + /sdcard/Download directory. Navigate to the file using the + method for the API level. For example, for API 22, this is the navigation + path: Settings > Device: Storage & USB + > Internal Storage > Explore + (Virtual SD Card).
Toggle trackball modeF6
+ +

Working With the Extended Controls, Settings, and Help

+ +

The extended controls let you send data, change device properties, control +apps, and more. To access the controls, select in the +emulator panel and then select the option you want in the left panel of the +Extended Controls dialog.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureDescriptionKeyboard Shortcuts
Location +

The emulator lets you simulate “my location” information: the location where +the emulated device is currently located. For example, if you click My Location +My Location icon + in Google Maps and then send a location, the map shows it.

+

To send a GPS location:

+
    +
  1. Select Decimal or Sexagesimal.
  2. +
  3. Specify the location.
  4. + +

    In decimal mode, enter a Latitude value in the range -90.0 +to +90.0 degrees and a Longitude value in the range -180.0 to ++180.0 degrees.

    +

    In sexigesimal mode, enter a three-part Latitude value in +the range -90 to +90 degrees, 0 to 59 minutes, and 0.0 to 60.0 +seconds. Enter a Longitude value in the range -180 to +180 +degrees, 0 to 59 minutes, and 0.0 to 60.0 seconds.

    +

    For the latitude, - indicates south and + indicates north; for the longitude, +- indicates west and + indicates east. The + is optional.

    +

    Optionally specify an Altitude value in the range +-1,000.0 to +10,000.0 meters.

    + +
  5. Click Send.
  6. +
+

To use geographic data from a GPS exchange format (GPX) or Keyhole Markup +Language (KML) file:

+
    +
  1. Click Load GPX/KML.
  2. +
  3. In the file dialog, select a file on your computer and click + Open.
  4. +
  5. Optionally select a Speed.
  6. +

    The speed defaults to the Delay value (Speed +1X). You can increase the speed by double (Speed +2X), triple (Speed 3X), and so on.

    + +
  7. Click Run Run icon.
  8. +
+
Ctrl+Shift+L
⇧⌘L
Cellular

The emulator lets you simulate various network conditions. You can + approximate the network speed for different network protocols, or you can + specify Full, which transfers data as quickly as your + computer allows. Specifying a network protocol is always slower than + Full. You can also specify the voice and data network + status, such as roaming. The defaults are set in the AVD.

+

Select a Network type:

+
    +
  • GSM - Global System for Mobile Communications
  • +
  • HSCSD - High-Speed Circuit-Switched Data
  • +
  • GPRS - Generic Packet Radio Service
  • +
  • EDGE - Enhanced Data rates for GSM Evolution
  • +
  • UMTS - Universal Mobile Telecommunications System
  • +
  • HSPDA - High-Speed Downlink Packet Access
  • +
  • Full (default)
  • +
+

Select a Voice status, Data status, or +both:

+
    +
  • Home (default)
  • +
  • Roaming
  • +
  • Searching
  • +
  • Denied (emergency calls only)
  • +
  • Unregistered (off)
  • +
+
Ctrl+Shift+C
⇧⌘C
Battery

You can simulate the battery properties of a device to see how your + app performs under different conditions. To select a Charge + level, use the slider control.

+

Select a Charger connection value:

+
    +
  • None
  • +
  • AC charger
  • +
+

Select a Battery health value:

+
    +
  • Good (default)
  • +
  • Failed
  • +
  • Dead
  • +
  • Overvoltage
  • +
  • Overheated
  • +
  • Unknown
  • +
+

Select a Battery status value:

+
    +
  • Unknown
  • +
  • Charging (default)
  • +
  • Discharging
  • +
  • Not charging
  • +
  • Full
  • +
+
Ctrl+Shift+B
⇧⌘B
Phone

The emulator lets you simulate incoming phone calls and text + messages. Note that the information flow is one way, from the control to + the emulator. For example, the control doesn’t change its state if the + emulator hangs up; you need to end the call in the control.

+

To initiate a call to the emulator:

+
    +
  1. Select or type a phone number in the From field.
  2. +
  3. Click Call Device.
  4. +
  5. Optionally click Hold Call to put the call on hold.
  6. +
  7. To end the call, click End Call.
  8. +
+

To send a text message to the emulator:

+
    +
  1. Select or type a phone number in the From field.
  2. +
  3. Type a message in the SMS message field.
  4. +
  5. Click Send Message.
  6. +
+
Ctrl+Shift+P
⇧⌘P
Directional Pad

If the AVD has the directional pad enabled in the hardware profile, + you can use the directional pad controls with the emulator. However, not + all devices can support the directional pad; for example, an Android watch. + The buttons simulate the following actions:

+Directional Pad Control +
Ctrl+Shift+D
⇧⌘D
Fingerprint

This control can simulate 10 different fingerprint scans. You can + use it to test fingerprint integration in your app. This feature isn't + supported for Android Wear.

+

To simulate a fingerprint scan on the virtual device:

+
    +
  1. Prepare an app to receive a fingerprint.
  2. +
  3. Select a Fingerprint value.
  4. +
  5. Click Touch Sensor.
  6. +
+
Ctrl+Shift+F
⇧⌘F
Settings

You can specify the following settings:

+
    +
  • Emulator window theme - Select Light or Dark.
  • +
  • Send keyboard shortcuts to - By default, some keyboard + combinations will trigger emulator control shortcuts. If you’re developing + an app that includes keyboard shortcuts, such as one targeted at + devices with Bluetooth keyboards, you can change this setting to send + all keyboard input to the virtual device, including input + that would be a shortcut in the emulator.
  • +
  • Screenshot save location - Click the folder icon to + specify a location to save screenshots of the emulator screen.
  • +
  • Use detected ADB location - If you're running the + emulator from Android Studio, you should select this setting (the default). + If you run the emulator from outside Android Studio and want it to use a + specific adb executable, deselect this option and specify the SDK Tools + location. If this setting is incorrect, features such as drag-and-drop app + install and file copy, and screenshot capture, won't work.
  • +
  • When to send crash reports - Select Always, Never, or + Ask.
  • +
+
Ctrl+Shift+S
⇧⌘S
Help > Keyboard Shortcuts

See the keyboard shortcuts that the emulator accepts. For the + shortcuts to work, you need to:

+
    +
  • Select Settings > Send keyboard shortcuts + to > Emulator controls (default).
  • +
+
F1
⌘/
Help > Emulator Help

To go to the online documentation for the emulator, click + Documentation.

+

To file a bug against the emulator, click File a Bug. +

+

To make suggestions, click Send Feedback.

+

All of these links require an internet connection and a browser.

F1
⌘/
Help > About

See which adb port the emulator uses, as well as the Android and + emulator version numbers. Compare the latest available emulator version + with your version to determine if you have the latest software installed. +

+

The emulator serial number is emulator-adb_port, + which you can specify as an adb command line option, for example.

F1
⌘/
+ -

Troubleshooting Emulator Problems

-

The {@code adb} utility sees the emulator as an actual physical device. For this reason, you -might have to use the {@code -d} flag with some common {@code adb} commands, such as -install. The {@code -d} flag lets you specify which of several connected devices to use -as the target of a command. If you don't specify {@code -d}, the emulator targets the first -device in its list. For more information about {@code adb}, see Android Debug Bridge.

-

For emulators running on Mac OS X, if you see an error {@code Warning: No DNS servers found} -when starting the emulator, check to see whether you have an /etc/resolv.conf file. If -not, please run the following line in a command window:

-
ln -s /private/var/run/resolv.conf /etc/resolv.conf
-

See Frequently Asked Questions for more -troubleshooting information.

diff --git a/docs/html/tools/help/emulator.jd b/docs/html/tools/help/emulator.jd index fa101e19638ef..08e3f6f345980 100644 --- a/docs/html/tools/help/emulator.jd +++ b/docs/html/tools/help/emulator.jd @@ -1,6 +1,4 @@ -page.title=Android Emulator -parent.title=Tools -parent.link=index.html +page.title=Using Android Emulator Command-Line Features @jd:body
@@ -8,14 +6,63 @@ parent.link=index.html

In this document

    -
  1. Keyboard Commands
  2. -
  3. Command Line Parameters
  4. +
  5. Starting and Stopping the Emulator
  6. +
  7. Installing Applications on the Emulator
  8. +
  9. Using Command Line Parameters
  10. +
  11. Using Hardware Acceleration +
      +
    1. Configuring Graphics Acceleration
    2. +
    3. Configuring Virtual Machine Acceleration
    4. +
    +
  12. +
  13. Using SD Card Emulation +
      +
    1. Creating an SD card image
    2. +
    3. Copying files to an SD card image
    4. +
    5. Loading an SD card image
    6. +
    +
  14. +
  15. Working With Emulator Disk Images +
      +
    1. Default image files
    2. +
    3. Runtime images: user data and SD card
    4. +
    5. Temporary images
    6. +
    +
  16. +
  17. Setting Up Emulator Networking +
      +
    1. Network Address Space
    2. +
    3. Local Networking Limitations
    4. +
    5. Using Network Redirection
    6. +
    7. Configuring the Emulator's DNS Settings
    8. +
    9. Using the Emulator with a Proxy
    10. +
    11. Interconnecting Emulator Instances
    12. +
    13. Sending a Voice Call or SMS to Another Emulator Instance
    14. +
    +
  18. +
  19. Using the Emulator Console +
      +
    1. Port Redirection
    2. +
    3. Geo Location Provider Emulation
    4. +
    5. Hardware Events Emulation
    6. +
    7. Device Power Characteristics
    8. +
    9. Network Status
    10. +
    11. Network Delay Emulation
    12. +
    13. Network Speed Emulation
    14. +
    15. Telephony Emulation
    16. +
    17. SMS Emulation
    18. +
    19. VM State
    20. +
    21. Emulator Window
    22. +
    23. Terminating an Emulator Instance
    24. +
    +
  20. +
  21. Troubleshooting Emulator Problems

See also

    -
  1. Using the Android Emulator
  2. -
  3. Managing Virtual Devices
  4. +
  5. Running Apps in the Android Emulator
  6. +
  7. Managing AVDs with the AVD Manager
@@ -26,111 +73,81 @@ parent.link=index.html that runs on your computer. The emulator lets you develop and test Android applications without using a physical device.

-

This document is a reference to the available command line options and the keyboard mapping to -device keys. -For a complete guide to using the Android Emulator, see +

This page describes command line features that you can use with the +Android Emulator. +For information about using the Android Emulator UI, see Using the Android Emulator. +

-

Keyboard Commands

+

Starting and Stopping the Emulator

-

Table 1 summarizes the mappings between the emulator keys and the keys of your keyboard.

+

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 Android Studio +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. +

-

Table 1. Emulator keyboard mapping

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Emulated Device Key Keyboard Key
HomeHOME
Menu (left softkey)F2 or Page-up button
Star (right softkey)Shift-F2 or Page Down
BackESC
Call/dial button F3
Hangup/end call buttonF4
SearchF5
Power buttonF7
Audio volume up buttonKEYPAD_PLUS, Ctrl-F5
Audio volume down buttonKEYPAD_MINUS, Ctrl-F6
Camera buttonCtrl-KEYPAD_5, Ctrl-F3
Switch to previous layout orientation (for example, portrait, landscape)KEYPAD_7, Ctrl-F11
Switch to next layout orientation (for example, portrait, landscape)KEYPAD_9, Ctrl-F12
Toggle cell networking on/offF8
Toggle code profilingF9 (only with -trace startup option)
Toggle fullscreen modeAlt-Enter
Toggle trackball modeF6
Enter trackball mode temporarily (while key is pressed)Delete
DPad left/up/right/downKEYPAD_4/8/6/2
DPad center clickKEYPAD_5
Onion alpha increase/decreaseKEYPAD_MULTIPLY(*) / KEYPAD_DIVIDE(/)
+

To start an instance of the emulator from the command line, navigate to the +tools/ folder of the SDK. Enter emulator command +like this:

+ +
emulator -avd <avd_name> [<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.

+ +

When you run your app from Android Studio, it installs and launches the +app on your connected device or emulator (launching the emulator, if necessary). +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 Android Studio, 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.

-

Command Line Parameters

+

Installing Applications on the Emulator

+ +

If you don't have access to Android Studio, 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 .apk as 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-data option. +For more information about the user-data partition and other emulator storage, +see Working with Emulator Disk Images.

+ +

Using Command Line Parameters

The emulator supports a variety of options that you can specify when launching the emulator, to control its appearance or behavior. @@ -579,3 +596,1339 @@ with AVD Manager.   + + +

Using Hardware Acceleration

+ +

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.

+ + +

Configuring Graphics Acceleration

+ +

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 {@link +android.webkit.WebView} component are not compatible with graphics acceleration.

+ +

To configure an AVD to use graphics acceleration:

+ +
    +
  1. Make sure you have the required SDK components installed (listed above).
  2. +
  3. Start the AVD Manager and create a new AVD with the Target value of +Android 4.0.3 (API Level 15), revision 3 or higher.
  4. +
  5. If you want to have graphics acceleration enabled by default for this AVD, in the +Hardware section, click New, select GPU emulation +and set the value to Yes. +

    Note: You can also enable graphics acceleration when you +start an emulator using command line options as describe in the next section.

    +
  6. +
  7. Name the AVD instance and select any other configuration options. +

    Caution: Do not select the Snapshot: Enabled +option. Snapshots are not supported for emulators with graphics acceleration enabled.

    +
  8. +
  9. Click Create AVD to save the emulator configuration.
  10. +
+ +

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:

+ + + + +

Configuring Virtual Machine Acceleration

+ +

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:

+ +
    +
  1. In the Android SDK Manager, make sure you have an x86-based System Image + installed for your target Android version. If you do not have an x86 System + Image installed, select one in the Android SDK Manager and install it. +

    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.

    +
  2. +
  3. Start the AVD Manager and create a new AVD with an x86 value for the +CPU/ABI field. You may need to select a specific Target value, or +select a Target value and then select a specific CPU/ABI +option.
  4. +
  5. Name the emulator instance and select any other configuration options.
  6. +
  7. Click Create AVD to save the emulator configuration.
  8. +
+ +

Configuring VM Acceleration on Windows

+ +

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:

+ +
    +
  1. Start the Android SDK Manager, select Extras and then select Intel +Hardware Accelerated Execution Manager.
  2. +
  3. After the download completes, execute {@code +<sdk>/extras/intel/Hardware_Accelerated_Execution_Manager/IntelHAXM.exe}.
  4. +
  5. Follow the on-screen instructions to complete installation.
  6. +
  7. After installation completes, confirm that the virtualization driver is operating correctly by +opening a command prompt window and running the following command: +
    sc query intelhaxm
    +

    You should see a status message including the following information:

    +
    +SERVICE_NAME: intelhaxm
    +       ...
    +       STATE              : 4  RUNNING
    +       ...
    +
    +
  8. +
+ +

To run an x86-based emulator with VM acceleration:

+ + +

You can adjust the amount of memory available to the Intel HAXM kernel extension by re-running +its installer.

+ +

You can stop using the virtualization driver by uninstalling it. Re-run the installer or use +the Control Panel to remove the software.

+ + +

Configuring VM Acceleration on Mac

+ +

Virtual machine acceleration on a Mac requires the installation of the Intel Hardware Accelerated +Execution Manager (Intel HAXM) kernel extension to allow the Android emulator to make use of CPU +virtualization extensions. The kernel extension is compatible with Mac OS X Snow Leopard (version +10.6.0) and higher.

+ +

To install the Intel HAXM kernel extension:

+ +
    +
  1. Start the Android SDK Manager, select Extras and then select Intel +Hardware Accelerated Execution Manager. +
  2. After the download completes, execute + {@code <sdk>/extras/intel/Hardware_Accelerated_Execution_Manager/IntelHAXM.dmg}.
  3. +
  4. Double click the IntelHAXM.mpkg icon to begin installation.
  5. +
  6. Follow the on-screen instructions to complete installation.
  7. +
  8. After installation completes, confirm that the new kernel extension is operating correctly by +opening a terminal window and running the following command: +
    kextstat | grep intel
    +

    You should see a status message containing the following extension name, indicating that the + kernel extension is loaded:

    +
    com.intel.kext.intelhaxm
    +
  9. +
+ +

To run an x86-based emulator with VM acceleration:

+ + +

You can adjust the amount of memory available to the Intel HAXM kernel extension by re-running +the installer.

+ +

You can stop using the virtualization kernel driver by uninstalling it. Before removing it, shut +down any running x86 emulators. To unload the virtualization kernel driver, run the following +command in a terminal window:

+ +
sudo /System/Library/Extensions/intelhaxm.kext/Contents/Resources/uninstall.sh
+ +

Configuring VM Acceleration on Linux

+ +

Linux-based systems support virtual machine acceleration through the KVM software package. Follow +instructions for installing KVM on your +Linux system, and verify that KVM is enabled. In addition to following the installation +instructions, be aware of these configuration requirements:

+ + + +

To run an x86-based emulator with VM acceleration:

+ + + +

Important: When using the {@code -qemu} command line option, make sure +it is the last parameter in your command. All subsequent options are interpreted as qemu-specific +parameters.

+ + +

Using SD Card Emulation

+ +

You can create a disk image and then load it to the emulator at startup, to +simulate the presence of a user's SD card in the device. To do this, you can specify +an SD card image when you create an AVD, or you can use the mksdcard utility included +in the SDK.

+ +

The following sections describe how to create an SD card disk image, how to copy +files to it, and how to load it in the emulator at startup.

+ +

Note that you can only load a disk image at emulator startup. Similarly, you +can not remove a simulated SD card from a running emulator. However, you can +browse, send files to, and copy/remove files from a simulated SD card either +with adb or the emulator.

+ +

The emulator supports emulated SDHC cards, so you can create an SD card image +of any size up to 128 gigabytes.

+ + +

Creating an SD card image

+ +

There are several ways of creating an SD card image. The easiest way is to use the +AVD Manager to create a new SD card by specifying a size when you create an AVD. +You can also use the {@code android} command line tool when creating an AVD. Just add the +-c option to your command:

+ +
android create avd -n <avd_name> -t <targetID> -c <size>[K|M]
+ +

The -c option can also be used to to specify a path to an SD card +image for the new AVD. For more information, see Managing Virtual Devices +from the Command Line. +

+ +

You can also use the mksdcard tool, included in the SDK, to create a FAT32 disk +image that you can load in the emulator at startup. You can access mksdcard in +the tools/ directory of the SDK and create a disk image like this:

+ +
mksdcard <size> <file>
+ +

For example:

+ +
mksdcard 1024M sdcard1.iso
+ +

For more information, see mksdcard.

+ + +

Copying files to an SD card image

+ +

Once you have created the disk image, you can copy files to it prior to +loading it in the emulator. To copy files, you can mount the image as a loop +device and then copy the files to it, or you can use a utility such as {@code mtools} to +copy the files directly to the image. The {@code mtools} package is available for Linux, +Mac, and Windows.

+ +

Alternatively, you can use the {@code adb push} command to move files onto an SD card image +while it is loaded in an emulator. For more information see the {@code adb push} documentation.

+ +

Loading an SD card image

+ +

By default, the emulator loads the SD card image that is stored with the active +AVD (see the -avd startup option).

+ +

Alternatively, you can start the emulator with the +-sdcard flag and specify the name and path of your image (relative +to the current working directory):

+ +
emulator -sdcard <filepath>
+ + +

Working With Emulator Disk Images

+ +

The emulator uses mountable disk images stored on your development machine to +simulate flash (or similar) partitions on an actual device. For example, it uses a +disk image containing an emulator-specific kernel, the Android system, a +ramdisk image, and writeable images for user data and simulated SD card.

+ +

To run properly, the emulator requires access to a specific set of disk image +files. By default, the Emulator always looks for the disk images in the +private storage area of the AVD in use. If no images exist there when +the Emulator is launched, it creates the images in the AVD directory based on +default versions stored in the SDK.

+ +

Note: The default storage location for +AVDs is in ~/.android/avd on OS X and Linux, C:\Documents and +Settings\<user>\.android\ on Windows XP, and +C:\Users\<user>\.android\ +on Windows Vista.

+ +

To let you use alternate or custom versions of the image files, the emulator +provides startup options that override the default locations and filenames of +the image files. When you use one of these options, the emulator searches for the image +file under the image name or location that you specify; if it can not locate the +image, it reverts to using the default names and location.

+ +

The emulator uses three types of image files: default image files, runtime +image files, and temporary image files. The sections below describe how to +override the location/name of each type of file.

+ +

Default image files

+ +

When the emulator launches, but does not find an existing user data image in +the active AVD's storage area, it creates a new one from a default version +included in the SDK. The default user data image is read-only. The image +files are read-only.

+ +

The emulator provides the -system <dir> startup option to +let you override the location where the emulator looks for the default +user data image.

+ +

The emulator also provides a startup option that lets you override the name +of the default user data image, as described in the following table. When you use the +option, the emulator looks in the default directory, or in a custom location +(if you specified -system <dir>).

+ + + + + + + + + + + + + + + + +
NameDescriptionComments
userdata.imgThe initial user-data disk imageOverride using -initdata <file>. Also see +-data <file>, below.
+ +

Runtime images: user data and SD card

+ +

At runtime, the emulator reads and writes data to two disk images: a +user-data image and (optionally) an SD card image. These images emulate the user-data +partition and removable storage media on actual device.

+ +

The emulator provides a default user-data disk image. At startup, the emulator +creates the default image as a copy of the system user-data image (user-data.img), +described above. The emulator stores the new image with the files of the active AVD.

+ + + +

The emulator provides startup options to let you override the actual names and storage +locations of the runtime images to load, as described in the following table. When you use one +of these options, the emulator looks for the specified file(s) in the current working directory, +in the AVD directory, or in a custom location (if you specified a path with the filename).

+ + + + + + + + + + + + + + + + + + + +
NameDescriptionComments
userdata-qemu.imgAn image to which the emulator writes runtime user-data for a unique user.Override using -data <filepath>, where <filepath> is the +path the image, relative to the current working directory. If you supply a filename only, +the emulator looks for the file in the current working directory. If the file at <filepath> does +not exist, the emulator creates an image from the default userdata.img, stores it under the name you +specified, and persists user data to it at shutdown.
sdcard.imgAn image representing an SD card inserted into the emulated device.Override using -sdcard <filepath>, where <filepath> is the +path the image, relative to the current working directory. If you supply a filename only, +the emulator looks for the file in the current working directory.
+ +

User-Data Image

+ +

Each emulator instance uses a writeable user-data image to store user- and +session-specific data. For example, it uses the image to store a unique user's +installed application data, settings, databases, and files.

+ +

At startup, the emulator attempts to load a user-data image stored during +a previous session. It looks for the file in the current working directory, +in the AVD directory described in a previous section and at the custom location/name +that you specified at startup.

+ + + +

Note: Because of the AVD configurations used in the emulator, +each emulator instance gets its own dedicated storage. There is no longer a need +to use the -d option to specify an instance-specific storage area.

+ +

SD Card

+ +

Optionally, you can create a writeable disk image that the emulator can use +to simulate removeable storage in an actual device. For information about how to create an +emulated SD card and load it in the emulator, see SD Card Emulation

+ +

You can also use the android tool to automatically create an SD Card image +for you, when creating an AVD. For more information, see Managing Virtual Devices with AVD +Manager. + + +

Temporary Images

+ +

The emulator creates two writeable images at startup that it deletes at +device power-off. The images are:

+ + + +

The emulator does not permit renaming the temporary system image or +persisting it at device power-off.

+ +

The /cache partition image is initially empty, and is used by +the browser to cache downloaded web pages and images. The emulator provides an +-cache <file>, which specifies the name of the file in which +to persist the /cache image at device power-off. If <file> + does not exist, the emulator creates it as an empty file.

+ +

You can also disable the use of the cache partition by specifying the +-nocache option at startup.

+ + +

Setting Up Emulator Networking

+ +

The emulator provides versatile networking capabilities that you can use to +set up complex modeling and testing environments for your application. The +sections below introduce the emulator's network architecture and capabilities. +

+ +

Network Address Space

+ +

Each instance of the emulator runs behind a virtual router/firewall service +that isolates it from your development machine's network interfaces and settings +and from the internet. An emulated device can not see your development machine +or other emulator instances on the network. Instead, it sees only that it is +connected through Ethernet to a router/firewall.

+ +

The virtual router for each instance manages the 10.0.2/24 network address +space — all addresses managed by the router are in the form of +10.0.2.<xx>, where <xx> is a number. Addresses within this space are +pre-allocated by the emulator/router as follows:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Network AddressDescription
10.0.2.1Router/gateway address
10.0.2.2Special alias to your host loopback interface (i.e., 127.0.0.1 on your +development machine)
10.0.2.3First DNS server
10.0.2.4 / 10.0.2.5 / 10.0.2.6Optional second, third and fourth DNS server (if any)
10.0.2.15The emulated device's own network/ethernet interface
127.0.0.1The emulated device's own loopback interface
+ +

Note that the same address assignments are used by all running emulator +instances. That means that if you have two instances running concurrently on +your machine, each will have its own router and, behind that, each will have an +IP address of 10.0.2.15. The instances are isolated by a router and can +not see each other on the same network. For information about how to +let emulator instances communicate over TCP/UDP, see Connecting Emulator Instances.

+ +

Also note that the address 127.0.0.1 on your development machine corresponds +to the emulator's own loopback interface. If you want to access services running +on your development machine's loopback interface (a.k.a. 127.0.0.1 on your +machine), you should use the special address 10.0.2.2 instead.

+ +

Finally, note that each emulated device's pre-allocated addresses are +specific to the Android emulator and will probably be very different on real +devices (which are also very likely to be NAT-ed, i.e., behind a +router/firewall)

+ + +

Local Networking Limitations

+ +

Android applications running in an emulator can connect to the network available on your +workstation. However, they connect through the emulator, not directly to hardware, and the emulator +acts like a normal application on your workstation. This means that the emulator, and thus your +Android applications, are subject to some limitations:

+ + + +

The emulator's virtual router should be able to handle all outbound TCP and +UDP connections/messages on behalf of the emulated device, provided your +development machine's network environment allows it to do so. There are no +built-in limitations on port numbers or ranges except the one imposed by your +host operating system and network.

+ +

Depending on the environment, the emulator may not be able to support other +protocols (such as ICMP, used for "ping") might not be supported. Currently, the +emulator does not support IGMP or multicast.

+ +

Using Network Redirection

+ +

To communicate with an emulator instance behind its virtual router, you need +to set up network redirection on the virtual router. Clients can then connect +to a specified guest port on the router, while the router directs traffic +to/from that port to the emulated device's host port.

+ +

To set up the network redirection, you create a mapping of host and guest +ports/addresses on the emulator instance. There are two ways to set up +network redirection: using emulator console commands and using the ADB tool, as +described below.

+ + +

Setting up Redirection through the Emulator Console

+ +

Each emulator instance provides a control console the you can connect to, to +issue commands that are specific to that instance. You can use the +redir console command to set up redirection as needed for an +emulator instance.

+ +

First, determine the console port number for the target emulator instance. +For example, the console port number for the first emulator instance launched is +5554. Next, connect to the console of the target emulator instance, specifying +its console port number, as follows:

+ +
telnet localhost 5554
+ +

Once connected, use the redir command to work with redirection. +To add a redirection, use:

+ +
add <protocol>:<host-port>:<guest-port>
+
+ +

where <protocol> is either tcp or udp, +and <host-port> and <guest-port> sets the +mapping between your own machine and the emulated system, respectively.

+ +

For example, the following command sets up a redirection that handles all +incoming TCP connections to your host (development) machine on 127.0.0.1:5000 +and will pass them through to the emulated system's 10.0.2.15:6000.:

+ +
redir add tcp:5000:6000
+ +

To delete a redirection, you can use the redir del command. To +list all redirection for a specific instance, you can use redir +list. For more information about these and other console commands, see +Using the Emulator Console.

+ +

Note that port numbers are restricted by your local environment. this typically +means that you cannot use host port numbers under 1024 without special +administrator privileges. Also, you won't be able to set up a redirection for a +host port that is already in use by another process on your machine. In that +case, redir generates an error message to that effect.

+ +

Setting Up Redirection through ADB

+ +

The Android Debug Bridge (ADB) tool provides port forwarding, an alternate +way for you to set up network redirection. For more information, see Forwarding Ports in the ADB +documentation.

+ +

Note that ADB does not currently offer any way to remove a redirection, +except by killing the ADB server.

+ + +

Configuring the Emulator's DNS Settings

+ +

At startup, the emulator reads the list of DNS servers that your system is +currently using. It then stores the IP addresses of up to four servers on this +list and sets up aliases to them on the emulated addresses 10.0.2.3, 10.0.2.4, +10.0.2.5 and 10.0.2.6 as needed.

+ +

On Linux and OS X, the emulator obtains the DNS server addresses by parsing +the file /etc/resolv.conf. On Windows, the emulator obtains the +addresses by calling the GetNetworkParams() API. Note that this +usually means that the emulator ignores the content of your "hosts" file +(/etc/hosts on Linux/OS X, %WINDOWS%/system32/HOSTS + on Windows).

+ +

When starting the emulator at the command line, you can also use the +-dns-server <serverList> option to manually specify the +addresses of DNS servers to use, where <serverList> is a comma-separated +list of server names or IP addresses. You might find this option useful if you +encounter DNS resolution problems in the emulated network (for example, an +"Unknown Host error" message that appears when using the web browser).

+ + +

Using the Emulator with a Proxy

+ +

If your emulator must access the Internet through a proxy server, you can use +the -http-proxy <proxy> option when starting the emulator, to +set up the appropriate redirection. In this case, you specify proxy information +in <proxy> in one of these formats:

+ +
http://<machineName>:<port>
+ +

or

+ +
http://<username>:<password>@<machineName>:<port>
+ +

The -http-proxy option forces the emulator to use the specified +HTTP/HTTPS proxy for all outgoing TCP connections. Redirection for UDP is not +currently supported.

+ +

Alternatively, you can define the environment variable +http_proxy to the value you want to use for +<proxy>. In this case, you do not need to specify a value for +<proxy> in the -http-proxy command — the +emulator checks the value of the http_proxy environment variable at +startup and uses its value automatically, if defined.

+ +

You can use the -verbose-proxy option to diagnose proxy +connection problems.

+ + +

Interconnecting Emulator Instances

+ +

To allow one emulator instance to communicate with another, you must set up +the necessary network redirection as illustrated below.

+ +

Assume that your environment is

+ + + +

and you want to run a server on B, to which C will connect, here is how you +could set it up:

+ +
    +
  1. Set up the server on B, listening to +10.0.2.15:<serverPort>
  2. +
  3. On B's console, set up a redirection from +A:localhost:<localPort> to +B:10.0.2.15:<serverPort>
  4. +
  5. On C, have the client connect to 10.0.2.2:<localPort>
  6. +
+ +

For example, if you wanted to run an HTTP server, you can select +<serverPort> as 80 and <localPort> as +8080:

+ + + +

Sending a Voice Call or SMS to Another Emulator Instance

+ +

The emulator automatically forwards simulated voice calls and SMS messages from one instance to +another. To send a voice call or SMS, use the dialer application or SMS application, respectively, +from one of the emulators.

+ +

To initiate a simulated voice call to another emulator instance:

+
    +
  1. Launch the dialer application on the originating emulator instance.
  2. +
  3. As the number to dial, enter the console port number of the instance you'd like to call. You can determine + the console port number of the target instance by checking its window title, where the + console port number is reported as "Android Emulator (<port>).
  4. +
  5. Press "Dial". A new inbound call appears in the target emulator instance.
  6. +
+ +

To send an SMS message to another emulator instance, launch the SMS application (if available). Specify the console port number of the target emulator instance as as the SMS address, enter the message text, and send the message. The message is delivered to the target emulator instance.

+ +

You can also connect to an emulator instance's console to simulate an incoming voice call or SMS. For more information, see Telephony Emulation and SMS Emulation. + + +

Using the Emulator Console

+ +

Each running emulator instance provides a console that lets you query and control the emulated +device environment. For example, you can use the console to manage port redirection, network +characteristics, and telephony events while your application is running on the emulator. To +access the console and enter commands, use telnet to connect to the console's port number.

+ +

To connect to the console of any running emulator instance at any time, use this command:

+ +
telnet localhost <console-port>
+ +

An emulator instance occupies a pair of adjacent ports: a console port and an {@code adb} port. +The port numbers differ by 1, with the {@code adb} port having the higher port number. The console +of the first emulator instance running on a given machine uses console port 5554 and {@code adb} +port 5555. Subsequent instances use port numbers increasing by two — for example, 5556/5557, +5558/5559, and so on. Up to 16 concurrent emulator instances can run a console facility.

+ +

To connect to the emulator console, you must specify a valid console port. If multiple emulator instances are running, you need to determine the console port of the emulator instance you want to connect to. You can find the instance's console port listed in the title of the instance window. For example, here's the window title for an instance whose console port is 5554:

+ +

Android Emulator (5554)

+ +

Alternatively, you can use the adb devices command, which prints a list of running emulator instances and their console port numbers. For more information, see Querying for Emulator/Device Instances in the adb documentation.

+ +

Note: The emulator listens for connections on ports 5554-5587 and accepts connections only from localhost.

+ +

Once you are connected to the console, you can then enter help [command] to see a list of console commands and learn about specific commands.

+ +

To exit the console session, use quit or exit.

+ +

The following sections below describe the major functional areas of the console.

+ + +

Port Redirection

+ +

You can use the console to add and remove port redirection while the emulator is running. After +you connect to the console, manage port redirection by entering the following command:

+ +
redir <list|add|del> 
+ +

The redir command supports the subcommands listed in the table below.

+ + + + + + + + + + + + + + + + + + + + + + + + +
Subcommand + DescriptionComments
listList the current port redirection. 
add <protocol>:<host-port>:<guest-port>Add a new port redirection.
  • <protocol> must be either "tcp" or "udp"
  • +
  • <host-port> is the port number to open on the host
  • +
  • <guest-port> is the port number to route data to on the emulator/device
  • +
del <protocol>:<host-port>Delete a port redirection.The meanings of <protocol> and <host-port> are listed in the previous row.
+ + +

Geo Location Provider Emulation

+ +

You can use the console to set the geographic location reported to the applications running +inside an emulator. Use the geo command to send a simple GPS fix to the +emulator, with or without NMEA 1083 formatting:

+ +
geo <fix|nmea>
+ +

The geo command supports the subcommands listed in the table below.

+ + + + + + + + + + + + + + + + + + +
SubcommandDescriptionComments
fix <longitude> <latitude> [<altitude>]Send a simple GPS fix to the emulator instance.Specify longitude and latitude in decimal degrees. Specify altitude in meters.
nmea <sentence>Send an NMEA 0183 sentence to the emulated device, as if it were sent from an emulated GPS modem.<sentence> must begin with '$GP'. Only '$GPGGA' and '$GPRCM' sentences are currently supported.
+ +

You can issue the geo command as soon as an emulator instance is running. The +emulator sets the location you enter by creating a mock location provider. This provider responds to +location listeners set by applications, and also supplies the location to the {@link +android.location.LocationManager}. Any application can query the location manager to obtain the +current GPS fix for the emulated device by calling: + +

LocationManager.getLastKnownLocation("gps")
+ +

For more information about the Location Manager, see {@link android.location.LocationManager}. +

+ +

Hardware Events Emulation

+ +

The {@code event} console commands sends hardware events to the emulator. The syntax for this +command is as follows:

+ +
event <send|types|codes|text>
+ +

The event command supports the subcommands listed in the table below.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Subcommand + DescriptionComments
send <type>:<code>:<value> [...]Send one or more events to the Android kernel. You can use text names or integers for <type> and <value>.
typesList all <type> string aliases supported by the event subcommands. 
codes <type>List all <codes> string aliases supported by the event + subcommands for the specified <type>. 
event text <message>Simulate keypresses to send the specified string of characters as a message,The message must be a UTF-8 string. Unicode posts will be reverse-mapped according to the current device keyboard. Unsupported characters will be discarded silently.
+ + +

Device Power Characteristics

+ +

The {@code power} command controls the power state reported by the emulator to applications. The +syntax for this command is as follows:

+ +
power <display|ac|status|present|health|capacity>
+ +

The event command supports the subcommands listed in the table below.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Subcommand DescriptionComments
displayDisplay battery and charger state. 
ac <on|off>Set AC charging state to on or off.  
status <unknown|charging|discharging|not-charging|full>Change battery status as specified. 
present <true|false>Set battery presence state. 
health <unknown|good|overheat|dead|overvoltage|failure>Set battery health state. 
capacity <percent>Set remaining battery capacity state (0-100). 
+ + +

Network Status

+ +

You can use the console to check the network status and current delay and speed characteristics. To do so, connect to the console and use the netstatus command. Here's an example of the command and its output.

+ +
network status
+
+ + +

Network Delay Emulation

+ +

The emulator lets you simulate various network latency levels, so that you can test your +application in an environment more typical of the actual conditions in which it will run. You can +set a latency level or range at emulator startup or you can use the console to change the latency, +while the application is running in the emulator.

+ +

To set latency at emulator startup, use the -netdelay emulator option with a +supported <delay> value, as listed in the table below. Here are some +examples:

+ +
emulator -netdelay gprs
+emulator -netdelay 40 100
+ +

To make changes to network delay while the emulator is running, connect to the console and use +the netdelay command with a supported <delay> value from the table +below.

+ +
network delay gprs
+ +

The format of network <delay> is one of the following (numbers are milliseconds):

+ + + + + + + + + + + + + + + + + + + + + + + +
ValueDescriptionComments
gprsGPRS(min 150, max 550)
edgeEDGE/EGPRS(min 80, max 400)
umtsUMTS/3G(min 35, max 200)
noneNo latency(min 0, max 0)
<num>Emulate an exact latency (milliseconds). 
<min>:<max>Emulate an specified latency range (min, max milliseconds). 
+ + +

Network Speed Emulation

+ +

The emulator also lets you simulate various network transfer rates. +You can set a transfer rate or range at emulator startup or you can use the console to change the +rate, while the application is running in the emulator.

+ +

To set the network speed at emulator startup, use the -netspeed emulator option with a supported +<speed> value, as listed in the table below. Here are some examples:

+ +
emulator -netspeed gsm
+emulator -netspeed 14.4 80
+ +

To make changes to network speed while the emulator is running, connect to the console and use +the netspeed command with a supported <speed> value from the table +below.

+ +
network speed 14.4 80
+ +

The format of network <speed> is one of the following (numbers are +kilobits/sec):

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ValueDescriptionComments
gsmGSM/CSD(Up: 14.4, down: 14.4)
hscsdHSCSD(Up: 14.4, down: 43.2)
gprsGPRS(Up: 40.0, down: 80.0)
edgeEDGE/EGPRS(Up: 118.4, down: 236.8)
umtsUMTS/3G(Up: 128.0, down: 1920.0)
hsdpaHSDPA(Up: 348.0, down: 14400.0)
fullno limit(Up: 0.0, down: 0.0)
<num>Set an exact rate used for both upload and download.
<up>:<down>Set exact rates for upload and download separately.
+ + +

Telephony Emulation

+ +

The Android emulator includes its own GSM emulated modem that lets you simulate telephony +functions in the emulator. For example, you can simulate inbound phone calls, establish data +connections and terminate them. The Android system handles simulated calls exactly as it would +actual calls. The emulator does not support call audio.

+ +

You can use the {@code gsm} command to access the emulator's telephony functions after connecting +to the console. The syntax for this command is as follows:

+ +
gsm <call|accept|busy|cancel|data|hold|list|voice|status> 
+ +

The gsm command supports the subcommands listed in the table below.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Subcommand DescriptionComments
call <phonenumber>Simulate an inbound phone call from <phonenumber>. 
accept <phonenumber>Accept an inbound call from <phonenumber> and change the call's state "active".You can change a call's state to "active" only if its current state is "waiting" or "held".
busy <phonenumber>Close an outbound call to <phonenumber> and change the call's state to "busy".You can change a call's state to "busy" only if its current state is "waiting".
cancel <phonenumber>Terminate an inbound or outbound phone call to/from <phonenumber>. 
data <state>Change the state of the GPRS data connection to <state>.Supported <state> values are:
+
    +
  • unregistered -- No network available
  • +
  • home -- On local network, non-roaming
  • +
  • roaming -- On roaming network
  • +
  • searching -- Searching networks
  • +
  • denied -- Emergency calls only
  • +
  • off -- Same as 'unregistered'
  • +
  • on -- same as 'home'
  • +
+
holdChange the state of a call to "held". You can change a call's state to "held" only if its current state is "active" or "waiting".
listList all inbound and outbound calls and their states. 
voice <state>Change the state of the GPRS voice connection to <state>.Supported <state> values are:
+
    +
  • unregistered -- No network available
  • +
  • home -- On local network, non-roaming
  • +
  • roaming -- On roaming network
  • +
  • searching -- Searching networks
  • +
  • denied -- Emergency calls only
  • +
  • off -- Same as 'unregistered'
  • +
  • on -- Same as 'home'
  • +
+
statusReport the current GSM voice/data state.Values are those described for the voice and data commands.
+ + +

SMS Emulation

+ +

The Android emulator console lets you generate an SMS message and direct it to an emulator +instance. Once you connect to an emulator instance, you can generate an emulated incoming SMS using +the following command:

+ +
sms send <senderPhoneNumber> <textmessage>
+ +

where <senderPhoneNumber> contains an arbitrary numeric string.

+ +

The console forwards the SMS message to the Android framework, which passes it through to an application that handles that message type.

+ + +

VM State

+ +

You can use the vm command to control the VM on an emulator instance. The syntax for +this command is as follows:

+ +
vm <start|stop|status>
+ +

The vm command supports the subcommands listed in the table below.

+ + + + + + + + + + + + + + + + + + + + + + +
SubcommandDescriptionComments
startStart the VM on the instance.  
stopStop the VM on the instance.  
startDisplay the current status of the VM (running or stopped).  
+ + +

Emulator Window

+ +

You can use the window command to manage the emulator window. The syntax for this +command is as follows:

+ +
window <scale>
+ +

The vm command supports the subcommands listed in the table below.

+ + + + + + + + + + + + +
SubcommandDescriptionComments
scale <scale>Scale the emulator window.A number between 0.1 and 3 that sets the 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.
+ + +

Terminating an Emulator Instance

+ +

You can terminate an emulator instance through the console, using the kill command.

+ + + + +

Troubleshooting Emulator Problems

+ +

The {@code adb} utility sees the emulator as an actual physical device. For this reason, you +might have to use the {@code -d} flag with some common {@code adb} commands, such as +install. The {@code -d} flag lets you specify which of several connected devices to use +as the target of a command. If you don't specify {@code -d}, the emulator targets the first +device in its list. For more information about {@code adb}, see Android Debug Bridge.

+ +

For emulators running on Mac OS X, if you see an error {@code Warning: No DNS servers found} +when starting the emulator, check to see whether you have an /etc/resolv.conf file. If +not, please run the following line in a command window:

+
ln -s /private/var/run/resolv.conf /etc/resolv.conf
+ +

See Frequently Asked Questions for more +troubleshooting information.

diff --git a/docs/html/tools/tools_toc.cs b/docs/html/tools/tools_toc.cs index f737770bb0e99..baa51bcc52c96 100644 --- a/docs/html/tools/tools_toc.cs +++ b/docs/html/tools/tools_toc.cs @@ -121,6 +121,16 @@
  • AVD Manager
  • + +
  • ProGuard
  • Tracer for OpenGL ES
  • - +
  • zipalign