Configure hardware acceleration for the Android Emulator

The Android Emulator can use hardware accelerationfeatures to improve performance, sometimes drastically. This page describes howyou can configure graphics and virtual machine (VM) acceleration to get higherperformance from the emulator.

Configure graphics acceleration

Graphics acceleration uses your computer's hardware (typically the GPU) to makescreen rendering faster. Android devices use OpenGL for Embedded Systems(OpenGL ES or GLES) for rendering both 2D and3D graphics on the screen.

When you create an Android Virtual Device (AVD) in the AVD Manager, you canspecify whether the emulator should use hardware or software to emulatethe GPU of the AVD. Hardware acceleration is recommended and is typicallyfaster. However, you might need to use software acceleration if your computeruses graphics drivers that aren't compatible with the emulator.

By default, the emulator decides whether to use hardware or softwaregraphics acceleration based on your computer setup. If your GPU hardware anddrivers are compatible, the emulator uses the GPU. Otherwise, the emulatoruses software acceleration (using your computer's CPU) to simulate GPUprocessing.

If you start the emulator from thecommand line, you can also overridethe graphics acceleration setting in the AVD for that virtual device instance.

Requirements

To use graphics acceleration, your development environment must meet thefollowing requirements:

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

Configure graphics acceleration in the AVD Manager

To configure graphics acceleration for an AVD, follow these steps:

Configure graphics acceleration from the command line

To specify a graphics acceleration type when you run an AVD from the commandline, include the -gpu option, as shown in the following example:

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

The value of mode can be set to one of the following options:

  • auto: Let the emulator choose between hardware or software graphicsacceleration based on your computer setup.
  • host: Use the GPU on your computer for hardware acceleration. This optiontypically provides the highest graphics quality and performance for theemulator. However, if your graphics drivers have issues rendering OpenGL, youmight need to use the swiftshader_indirect or angle-indrect options.
  • swiftshader_indirect: Use a Quick Boot-compatible variant of SwiftShaderto render graphics using software acceleration. This option is a goodalternative to host mode if your computer can't use hardware acceleration.
  • angle_indirect: (Windows only) Use a Quick Boot-compatible variant of ANGLE Direct3Dto render graphics using software acceleration. This option is a goodalternative to host mode if your computer can't use hardware acceleration.In most cases, ANGLE performance should be similar to using host modebecause ANGLE uses Microsoft DirectX instead of OpenGL. On Windows, MicrosoftDirectX drivers typically have fewer issues than OpenGL drivers. This optionuses Direct3D 11 and requires Windows 10, Windows 8.1, or Windows 7 SP1 withthe Windows 7 Platform Update.
  • guest: Use guest-side software rendering. This option provides the lowestgraphics quality and performance for the emulator.
    Note: If you enable a graphics acceleration option that your computer doesn'tsupport, you are likely to see incorrect images displayed during emulation.

The following mode options are deprecated:

  • swiftshader: Deprecated in version 27.0.2 Use swiftshader_indirect instead.
  • angle: Deprecated in version 27.0.2. Use angle_indirect instead (Windows only).
  • mesa: Deprecated in version 25.3. Use swiftshader_indirect instead.

Enable Skia rendering for Android UI

When using images for API level 27 or higher, the emulator can render theAndroid UI with Skia. Skia helps theemulator render graphics more smoothly and efficiently.

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

  1. su
  2. setprop debug.hwui.renderer skiagl
  3. stop
  4. start

Configuring VM acceleration

VM acceleration uses your computer's processor to significantly improve theexecution speed of the emulator. A tool called a hypervisor manages thisinteraction using virtualization extensions that your computer's processorprovides. This section outlines the requirements for using VM acceleration anddescribes how to set up VM acceleration on each operating system.

General requirements

To use VM acceleration with the emulator, your computer must meet the generalrequirements in this section. Your computer also needs to meet otherrequirements that are specific to your operating system.

Development environment requirements

To use VM acceleration, your development environment must meet thefollowing 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
    Warning: AVDs that use ARM- or MIPS-based system images can't use the VMacceleration that is described on this page.

Virtualization extension requirements

In addition to the development environment requirements, your computer'sprocessor must support one of the following virtualization extensionstechnologies:

  • Intel Virtualization Technology (VT, VT-x, vmx) extensions
  • AMD Virtualization (AMD-V, SVM) extensions
    Most modern processors support these virtualization extensions. If you're notsure whether your processor supports these extensions, check the specificationsfor your processor on the manufacturer's site. If your processor doesn't supportone of these extensions, then you can't use VM acceleration.

Note: Virtualization extensions are typically enabled through your computer BIOSand are frequently turned off by default. Check the documentation for yourmotherboard to find out how to enable virtualization extensions.

Restrictions

VM acceleration has the following restrictions:

  • You can't run a VM-accelerated emulator inside another VM, such as a VM hostedby VirtualBox, VMWare, or Docker. You must run a VM-accelerated emulatordirectly on your host computer.
  • Depending on your operating system and hypervisor, you can't run software thatuses another virtualization technology at the same time that you run aVM-accelerated emulator. For example, VirtualBox, VMWare, and Docker currentlyuse a different virtualization technology, so you can't run them at the sametime as the accelerated emulator.

About hypervisors

VM acceleration requires a hypervisor.

Without a hypervisor and VM acceleration, the emulator must translate themachine code from the VM block by block to conform to the architecture of thehost computer. This process can be quite slow. With a hypervisor, the VM andthe architecture of the host computer match, so the emulator can run codedirectly on the host processor using the hypervisor. This improvementdrastically increases both the speed and performance of the emulator.

The hypervisor that will work best for you depends on your computer's operatingsystem and configuration. For more information, see one of the followingsections:

Check if a hypervisor is installed

You can use the emulator -accel-check command-line option to check ifa hypervisor is currently installed on your computer.

The following examples show how to use use the emulator accel-check option. Ineach example, sdk is the location of the Android SDK:

Windows:

  1. c:\Users\janedoe\AppData\Local\Android> sdk\emulator\emulator -accel-check
  2. accel:
  3. 0
  4. HAXM version 7.3.2 (4) is installed and usable.
  5. accel

macOS:

  1. janedoe:~/Android$ ./sdk/emulator/emulator -accel-check
  2. accel:
  3. 0
  4. HAXM version 7.3.2 (4) is installed and usable.
  5. accel

Linux:

  1. janedoe-macbookpro:Android janedoe$ ./sdk/emulator/emulator -accel-check
  2. accel:
  3. 0
  4. KVM (version 12) is installed and usable.

Configure VM acceleration on Windows

VM acceleration on Windows can use one of two hypervisors: the Intel HardwareAccelerated Execution Manager (HAXM) or the Windows Hypervisor Platform (WHPX).

Choose a hypervisor on Windows

Use the following criteria to determine which hypervisor you should use:

CriteriaHypervisor
You have an Intel processor and do not need to run Hyper-V at the same time as the Android Emulator.Use Intel HAXM.
You have an Intel processor and do need to run Hyper-V at the same time as the Android Emulator.Use WHPX.
You have an AMD processor.Use WHPX.

Configure VM acceleration using Intel HAXM on Windows

Before you can install and use Intel HAXM, your computer must meet the followingrequirements:

  • Intel processor with Virtualization Technology (VT-x), Intel EM64T(Intel 64) features, and Execute Disable (XD) Bit functionality enabled
  • 64-bit Windows 10, Windows 8, or Windows 7 (or 32-bit version of the operatingsystem on a 64-bit processor)
  • To use Intel HAXM on Windows 10 or 8, you must turn off Hyper-V in the WindowsControl Panel.Note: Installing certain software might turn Hyper-V back on. Where possible,Android Studio tries to detect if Hyper-V is re-enabled and displays anoption that lets you turn Hyper-V off again.
    To install the Intel HAXM driver, follow these steps:

  • Open the SDK Manager.

  • Click the SDK Update Sites tab and then select Intel HAXM.
  • Click OK.
  • After the download finishes, run the installer.Typically, you can find the installer in the following location:sdk\extras\intel\Hardware_Accelerated_Execution_Manager\intelhaxm-android.exe
  • Use the wizard to complete the installation.
  • After installing Intel HAXM, confirm that the virtualization driver isoperating correctly by entering the following command in a Command Promptwindow:
  1. sc query intelhaxm

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

  1. SERVICE_NAME: intelhaxm
  2. ...
  3. STATE : 4 RUNNING
  4. ...

For more information, seeInstallation Instructions for Intel HAXM on Windows.

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

You can uninstall Intel HAXM using either the installer or the Windows ControlPanel. Before you uninstall Intel HAXM, shut down any x86 emulators that arecurrently running.

Configure VM acceleration using Windows Hypervisor Platform

Before you can enable WHPX, your computer must meet the following requirements:

  • Intel processors: Support for Virtualization Technology (VT-x), Extended PageTables (EPT), and Unrestricted Guest (UG) features. VT-x must be enabled in yourcomputer's BIOS settings.
  • AMD processors: AMD Ryzen processor recommended. Virtualization or SVM mustbe enabled in your computer's BIOS settings.
  • Android Studio 3.2 Beta 1 or higher (download from developer.android.com)
  • Android Emulator version 27.3.8 or higher (download using the SDK Manager)
  • Windows 10 with April 2018 Update or higher
    To install WHPX on Windows, follow these steps:

  • From the Windows desktop, right-click the Windows icon and selectApps and features.

  • Under Related settings, click Programs and Features.
  • Click Turns Windows Features on or off.
  • Select Windows Hypervisor Platform

Configure hardware acceleration - 图1

  • Click OK.

  • Once the installation has finished, restart your computer.

Configure VM acceleration on macOS

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

To use VM acceleration on macOS when the Hypervisor.Framework is not available,you must install the Intel HAXM kernel extension.

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

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

  • Open the SDK Manager.
  • Click the SDK Update Sites tab and then select Intel HAXM.
  • Click OK.
  • After the download finishes, run the installer.Typically, you can find the installer in the following location:sdk/extras/intel/Hardware_Accelerated_ExecutionManager/IntelHAXMversion.dmg
  • Follow the on-screen instructions to complete the installation.
  • After installation finishes, confirm that the new kernel extension isoperating correctly by opening a terminal window and running the followingcommand:
  1. kextstat | grep intel

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

  1. com.intel.kext.intelhaxm

For more information, seeInstallation Instructions for Intel HAXM.

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

You can stop using the Intel HAXM kernel extension by uninstalling it. Beforeyou uninstall it, shut down any x86 emulators that are currently running, thenrun the following command in a terminal window:

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

Configure 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 verifythat KVM is enabled. For Ubuntu systems, see Ubuntu KVM Installation.

Requirements

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

To use VM acceleration on Linux, your computer must also meet theserequirements:

  • For Intel processors: Support for Virtualization Technology (VT-x), IntelEM64T (Intel 64) features, and Execute Disable (XD) Bit functionality enabled.
  • For AMD processors: Support for AMD Virtualization (AMD-V).

Check whether KVM is currently installed on Linux

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

The following example shows how to use the kvm-ok command:

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

Install KVM on Linux

Use the following command to install KVM:

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