Start the emulator from the command line

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

    Use the command to start the emulator, as analternative to runningyour project or .

    Here's the basic command-line syntax for starting a virtual device from aterminal prompt:

    Or

    1. emulator @avd_name [ {-option [value]} ]

    For example, if you launch the emulator from within Android Studio running on a Mac, the defaultcommand line will be similar to the following:

    1. $ /Users/janedoe/Library/Android/sdk/emulator/emulator -avd Nexus_5X_API_23 -netdelay none -netspeed full

    You can specify startup options when you start the emulator, but not lateron.

    For a list of AVD names, enter the following command:

    1. emulator -list-avds

    When you use this option, it displays a list of AVD names from your Android homedirectory. Note that you can override the default home directory by setting theANDROID_SDK_HOMEenvironment variable: the root of theuser-specific directory where all configuration and AVD content is stored. Youcould set the environment variable in the terminal window before launching avirtual device, or you could set it through your user settings in the operatingsystem; for example, in your .bashrc file on Linux.

    To stop the Android Emulator, just close the emulator window.

    In addition to installing an app through AndroidStudio or the , you can install your app on a virtual device by using the adb utility.

    To install an app by using adb, and then run and test the app,follow these general steps:

    • Build and package your app into an APK as described in .
    • Start the emulator from the command line as described in the previoussection, using any startup options necessary.
    • Install your app using adb.
    • Run and test your app on the emulator.While the emulator isrunning, you can also use the to issue commands as needed.
    • The virtual device preserves the app and its state data across restarts,in a user-data disk partition (userdata-qemu.img). To clear thisdata, start the emulator with the -wipe-data option or wipe thedata in the AVD Manager, for example. For more information about the user-datapartition and other storage, see the following section.To uninstall an app, doso as you would on an Android device.

    Note: The adb utility sees the virtual device asan actual physical device. For this reason, you might have to use the-d flag with some common adb commands, such asinstall. The -d flag lets you specify which of severalconnected devices to use as the target of a command. If you don't specify-d, the emulator targets the first device in its list.

    The Android Emulator uses the Quick Emulator (QEMU) hypervisor. Initial versions of theAndroid Emulator used QEMU 1 (goldfish), and later versions use QEMU 2 (ranchu).

    The system directory contains the Android system images that the emulator usesto simulate the operating system. It has platform-specific, read-only filesshared by all AVDs of the same type, including API level, CPU architecture, andAndroid variant. The default locations are the following:

    • Mac OS X and Linux - ~/Library/Android/sdk/system-images/android-apiLevel/variant/arch/
    • Microsoft Windows XP - C:\Documents and
      Settings\user\Library\Android\sdk\system-images\android-apiLevel\variant\arch
      \
    • Windows Vista - C:\Users\user\Library\Android\sdk\system-images\android-apiLevel\variant\arch\
      Where:

    • apiLevel is a numeric API level, or a letter forpreview releases. For example, android-M indicated the AndroidMarshmallow preview. On release, it became API level 23, designated byandroid-23.

    • variant is a name corresponding to specific featuresimplemented by the system image; for example, google_apis orandroid-wear.
    • arch is the target CPU architecture; for example,x86.
      Use the -sysdir option to specify a different system directory forthe AVD.

    The emulator reads the following files from the system directory.

    AVD data directory

    The AVD data directory, also called the content directory, is specific to asingle AVD instance and contains all modifiable data for the AVD.

    The default location is the following, where name is theAVD name:

    • Mac OS X and Linux - ~/.android/avd/name.avd/
    • Microsoft Windows XP - C:\Documents and
      Settings\user.android\name.avd\
    • Windows Vista, and higher -C:\Users\user.android\name.avd\
      Use the -datadir option to specify a different AVD data directory.

    The following table lists the most important files contained in this directory.

    Listing directories and files used by the emulator

    You can discover where files are located in two ways:

    • When you start the emulator from the command line, use the-verbose or -debug init option, and look at theoutput.
    • Use the emulator -help-option command tolist a default directory. For example:
    1. $ emulator -help-datadir
    2. Use '-datadir <dir>' to specify a directory where writable image files
    3. will be searched. On this system, the default directory is:
    4.  
    5. /Users/me/.android
    6.  
    7. See '-help-disk-images' for more information about disk image files.

    This section lists options you can supply on the command line when you start theemulator.

    Note: The Android Emulator is continually under development tomake it more reliable. For status on the issues reported against various command-line options,and to report bugs, see the .

    The following table lists command-line startup options that you might use more often.

    Advanced options

    In the descriptions, the working directory is the current directory inthe terminal where you're entering commands. For information about the AVDsystem directory and data directory, and the files storedwithin them, see Understanding thedefault directories and files.

    Some of these options are appropriate for external app developers, and some ofthem are used primarily by platform developers. App developers createAndroid apps and run them on specific AVDs. Platform developers work onthe Android system and run it inside the emulator with no pre-created AVD;they're internal Android team members, not external app developers.

    Deprecated options

    The following command-line options are deprecated:

    • -audio-in
    • -audio-out
    • -charmap
    • -code-profile
    • -cpu-delay
    • -dpi-device
    • -dynamic_skin
    • -enable-kvm
    • -gps
    • -image
    • -keyset
    • -help-keys
    • -help-keyset-file
    • -nand-limits
    • -noskin
    • -no-skin
    • -onion
    • -onion-alpha
    • -onion-rotation
    • -radio
    • -ranchu
    • -raw-keys
    • -scale
    • -shared-net-id
    • -shell-serial
    • -skin
    • -skindir
    • -trace
    • -useaudio

    This section describes how to get help about the command-line options. Thefollowing section provides more in-depth information about the commonly usedemulator command-line options that are available when you start the emulator.

    To print a list of all emulator options, including a short description, enterthis command:

    1. emulator -help

    Getting detailed help for a specific option

    To print help for a specific startup option, enter this command:

    1. emulator -help-option

    For example:

    1. emulator -help-netspeed

    This help is more detailed than the description provided by the-help option.

    Getting detailed help for all options

    To get detailed help for all emulator options, enter this command:

    1. emulator -help-all

    To get a list of emulator environment variables, enter this command:

      You can set environment variables in the terminal window before launching avirtual device, or you could set it through your user settings in the operatingsystem; for example, in your .bashrc file on Linux.

      Listing debug tags

      To print a list of tags for the -debug options, enter this command:

      1. emulator -help-debug-tags