Configure Emulator graphics rendering and hardware acceleration

The Android Emulator can use several hardware acceleration features to improve performance, sometimes drastically. Android Studio typically prompts you to install any required software and suggests the best configuration for your development computer. This page describes how you can fine-tune the graphics and virtual machine (VM) acceleration settings, if needed, and manually install VM acceleration software.

Configuring graphics acceleration

Graphics acceleration for the emulator takes advantage of the graphics hardware on your development computer, specifically the graphics processing unit (GPU), to make screen rendering faster. Android devices use OpenGL for Embedded Systems (OpenGL ES or GLES) for rendering both 2D and 3D graphics on the screen.

When you create an Android Virtual Device (AVD) in the AVD Manager, you can specify that graphics acceleration occur in hardware or software to emulate the GPU of the virtual device. Hardware acceleration is typically faster. Software acceleration is useful if your computer uses graphics drivers that aren't compatible with the emulator, in which case hardware graphics rendering can be poor or cause the emulator to crash.

The default is to let the emulator decide if it should use hardware or software graphics acceleration based on your computer setup. If the GPU hardware and drivers are compatible, the emulator uses the GPU; otherwise, the emulator uses the CPU to simulate GPU processing.

If you start the emulator from the command line, you can override the graphics acceleration setting in the AVD for that virtual device instance, if needed.

Dependencies and prerequisites

Graphics acceleration has the following requirements:

  • SDK Tools: Latest release recommended (version 17 minimum)
  • SDK Platform: Latest release recommended (Android 4.0.3, Revision 3, minimum)

Configuring graphics acceleration in the AVD Manager

To configure an AVD to use hardware or software graphics acceleration, follow these steps:

  1. Open the AVD Manager.
  2. Create a new AVD or edit an existing AVD.
  3. In the Verify Configuration page, specify the Emulated Performance: Graphics setting.
  4. Caution: Snapshots are not supported for emulators with graphics acceleration enabled.

  5. To save the AVD, click Finish.

Configuring graphics acceleration on the command line

To specify a graphics acceleration type when you run an AVD from the command line, include the -gpu option:

emulator -avd avd_name -gpu mode [{-option [value]} ... ]

Where mode can be any of the following:

  • auto: Let the emulator choose hardware or software graphics acceleration based on your computer setup.
  • host: Use the GPU on your computer. This option is typically the fastest. However, some drivers have issues with rendering OpenGL graphics, so using the computer GPU might not be a reliable option.
  • swiftshader_indirect: Use a Quick Boot-compatible variant of SwiftShader to render graphics in software. It's slower than using the GPU, but normally yields good results. Added in revision 27.0.2.
  • angle_indirect: (Windows only) Use a Quick Boot-compatible variant of ANGLE Direct3D that renders graphics in software. This is a good alternative to host mode when your computer isn't compatible with the hardware acceleration in the emulator. In most cases, ANGLE performance should be similar to using -gpu host, which uses OpenGL instead of Microsoft DirectX. On Windows, Microsoft DirectX drivers normally have fewer issues than OpenGL drivers. This option uses Direct3D 11 and requires Windows 10, Windows 8.1, or Windows 7 SP1 + Windows 7 Platform Update. Added in revision 27.0.2.
  • guest: Use guest-side software rendering. This option is slow.

If you enable a graphics acceleration option that your computer doesn't support, you are likely to see incorrect images displayed.

The following mode options are deprecated:

  • angle: Deprecated in revision 27.0.2—instead use angle_indirect. (Windows only.) Use Almost Native Graphics Layer Engine (ANGLE) and Microsoft DirectX to render graphics in software.
  • swiftshader: Deprecated in revision 27.0.2—instead use swiftshader_indirect. Use SwiftShader to render graphics in software. It's slower than using the GPU, but normally yields good results. Added in revision 25.3.
  • mesa: Deprecated in revision 25.3—instead use swiftshader_indirect. Use the Mesa 3D software library to render graphics.

Enabling Skia rendering for Android UI

When using images for API 27 or later, the emulator can render the Android UI with Skia, which can render more smoothly and efficiently.

To enable Skia rendering, use the following commands in adb shell:

  su
  setprop debug.hwui.renderer skiagl
  stop
  start

Configuring VM acceleration

Many modern CPUs provide extensions for running VMs more efficiently. Taking advantage of these extensions with the emulator can require some additional configuration of your development computer, but can significantly improve the execution speed. This section outlines the VM acceleration requirements and setup steps for each operating system.

Dependencies and prerequisites

To use VM acceleration with the emulator, you need to meet the following Android development tools requirements:

  • SDK Tools: minimum version 17; recommended version 26.1.1 or later
  • AVD with an x86-based system image, available for Android 2.3.3 (API level 10) and higher

AVDs that use ARM- or MIPS-based system images can't be accelerated using the emulator configurations described on this page.

Virtualization extension requirements

Before attempting to use acceleration, you should first determine if your CPU supports one of the following virtualization extensions technologies:

  • Intel Virtualization Technology (VT, VT-x, vmx) extensions
  • AMD Virtualization (AMD-V, SVM) extensions

Most modern computers do. If you use an older computer and you're not sure, consult the specifications from the manufacturer of your CPU to determine if it supports virtualization extensions. If your CPU doesn't support one of these virtualization technologies, then you can't use VM acceleration.

Virtualization extensions are typically enabled through your computer BIOS and are frequently turned off by default. Check the documentation for your motherboard to find out how to enable virtualization extensions.

About hypervisors

Emulator acceleration requires a hypervisor. The recommended hypervisor on Mac computers and on Windows computers with Intel CPUs is Intel Hardware Accelerated Execution Manager (Intel HAXM). The hypervisor used on Linux is Kernel-based Virtual Machine (KVM). It is possible to use Windows Hypervisor Platform (WHPX) on Windows if you have an AMD CPU or need to use Hyper-V at the same time as the Android Emulator.

Without acceleration, the emulator takes the machine code from the VM and translates it block by block to conform to the architecture of the host computer. This process can be quite slow. But, if the VM and the architecture of the host computer match (such as x86 on x86), the emulator can skip translating the code and simply run it directly on the actual CPU using a hypervisor. In this case, the emulator can approach the speed of the host computer.

If the needed hypervisor isn't installed, Android Studio typically prompts you to install it. Typically, Android Studio prompts you to install the needed software when you do any of the following:

  • Install Android Studio and SDK Tools.
  • Create and manage AVDs in the AVD Manager.
  • Select an AVD to run from the Select Deployment Target dialog.

Determining whether HAXM or KVM is installed

If you ever need to check whether HAXM or KVM is installed, you can use the emulator -accel-check command-line option.

For example, here's sample output on a Mac, where sdk is the Android SDK location:

janedoe-macbookpro:tools janedoe$ ./sdk/tools/emulator -accel-check
accel:
0
HAXM version 6.0.3 (3) is installed and usable.
accel

For Linux:

janedoe:~/Android/Sdk/tools$ ./sdk/tools/emulator -accel-check
accel:
0
KVM (version 12) is installed and usable.
accel

VM acceleration restrictions

Note the following restrictions of VM acceleration:

  • You can't run a VM-accelerated emulator inside another VM, such as a VM hosted by VirtualBox, VMWare, or Docker. You must run the emulator directly on your system hardware.
  • You can't run software that uses another virtualization technology at the same time that you run the accelerated emulator. For example, VirtualBox, VMWare, and Docker currently use a different virtualization technology, so you can't run them at the same time as the accelerated emulator.

Configuring VM acceleration on Windows

The recommended configuration for VM acceleration of the emulator on on Windows uses HAXM on an Intel CPU. However, if you have an AMD CPU or need to run the emulator at the same time as Hyper-V (for example, while using Docker), then you can use these other configurations.

Warning: Some hardware setups are incompatible with WHPX or Hyper-V, and enabling of these features can cause Windows to fail to boot completely and instead show a black screen. In this case, you must disable virtualization in the BIOS and start Windows to disable WHPX or Hyper-V. For this reason, we recommend that you use the emulator with HAXM and an Intel CPU when possible.

Configuring VM acceleration with HAXM on Windows with an Intel CPU

VM acceleration for Windows on an Intel CPU requires the installation of Intel HAXM.

Requirements and recommendations:

  • Intel CPU with Virtualization Technology (VT-x) and Intel EM64T (Intel 64) features, with Execute Disable (XD) Bit functionality enabled
  • 64-bit Windows 7, Windows 8, or Windows 10 (or 32-bit version of the operating system on a 64-bit CPU)

To use HAXM on Windows 8 or 10, turn off Hyper-V in the Control Panel. Installing certain software might turn Hyper-V back on. In this case, where possible, Android Studio displays a "quick fix" link in certain dialogs that lets you easily turn Hyper-V off again.

To install the HAXM driver, follow these steps:

  1. Open the SDK Manager.
  2. Click the SDK Update Sites tab and then select Intel HAXM.
  3. Click OK.
  4. After the download finishes, run the installer.
    For example, it might be in this location:
    sdk\extras\intel\Hardware_Accelerated_Execution_Manager\intelhaxm-android.exe.
  5. Use the wizard to complete the installation.
  6. After installing HAXM, confirm that the virtualization driver is operating correctly by entering the following command in a Command Prompt window:
    sc query intelhaxm

    You should see a status message that includes the following information:

    SERVICE_NAME: intelhaxm
           ...
           STATE              : 4  RUNNING
           ...
    

    For more information, see Installation Instructions for Intel HAXM.

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

You can stop using the virtualization driver by uninstalling it. To remove the software, run the installer or use the Control Panel.

Configuring VM acceleration with Windows Hypervisor Platform

Though we recommend using HAXM on Windows, it is possible to use Windows Hypervisor Platform (WHPX) with the emulator. Situations in which you should use WHPX with the emulator are the following:

  • You need to use Hyper-V at the same time.
  • You are using an AMD CPU.

Requirements and recommendations:

  • Intel CPU requirements: Virtualization Technology (VT-x), Extended Page Tables (EPT), and Unrestricted Guest (UG) features
  • AMD CPU recommendation: AMD Ryzen CPU
  • Android Studio 3.2 Beta 1 or higher (Download here.)
  • Android Emulator version 27.3.8 or higher
  • Windows 10 with April 2018 Update or higher

To use WHPX acceleration on Windows, you must enable the Windows Hypervisor Platform option in the Turn Windows features on or off dialog box. For changes to this option to take effect, restart your computer.

Additionally, the following changes must be made in the BIOS settings:

  • Intel CPU: VT-x must be enabled.
  • AMD CPU: Virtualization or SVM must be enabled.

Configuring VM acceleration on Mac

On Mac OS X v10.10 Yosemite and higher, the Android Emulator uses the built-in Hypervisor.Framework by default, and falls back to using HAXM if Hypervisor.Framework fails to initialize.

To use VM acceleration on a Mac on which Hypervisor.Framework is not available, you must install the Intel HAXM kernel extension to allow the emulator to make use of CPU virtualization extensions.

Note for users of macOS 10.13 High Sierra and higher: macOS 10.13 disables installation of kernel extensions by default. Because HAXM is a kernel extension, you might need to manually enable its installation. For more details, see Known Issues.

To install the Intel HAXM kernel extension, follow these steps:

  1. Open the SDK Manager.
  2. Click the SDK Update Sites tab and then select Intel HAXM.
  3. Click OK.
  4. After the download finishes, run the installer.
    For example, it might be in this location:
    sdk/extras/intel/Hardware_Accelerated_Execution_Manager/IntelHAXM_version.dmg.
    To begin installation, in the Finder, double-click the IntelHAXM.dmg file and then the IntelHAXM.mpkg file.
  5. Follow the on-screen instructions to complete the installation.
  6. After installation finishes, 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

    For more information, see Installation Instructions for Intel HAXM.

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

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 VM acceleration through the KVM software package. Follow the instructions for installing KVM on your Linux system, and verify that KVM is enabled. For an example, see Ubuntu KVM Installation.

Running KVM requires specific user permissions. Make sure that you have sufficient permissions as specified in the KVM installation instructions.

To run an accelerated emulator on a Linux computer, it must also meet these requirements:

  • Intel processor with support for Intel VT-x, Intel EM64T (Intel 64), and Execute Disable (XD) Bit functionality enabled, or
  • AMD processor with support for AMD Virtualization (AMD-V)

You can use the emulator -accel-check command-line option to check whether you have KVM installed. Alternatively, you can install the cpu-checker package containing the kvm-ok command. For example:

$ sudo apt-get install cpu-checker
$ egrep -c '(vmx|svm)' /proc/cpuinfo
12
$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

If KVM is missing or to ensure you have the latest KVM installed, enter the following command line to install it:

$ sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils ia32-libs-multiarch