Sunday, November 4, 2018

Fix: Emulator: ERROR: x86 emulation currently requires hardware acceleration

Fixing "Emulator: ERROR: x86 emulation currently requires hardware acceleration"

I upgraded my Android Studio to 3.2.1 with Intel Core i7-2600K, and found following error upon running my old Android project.  A quick search come out with many hits, but most of them are incomplete.  A majority of them assumes we run on Intel CPU, and most of them assumes Intel HAXM not installed.  Nobody shows a complete step to verify BIOS, CPU, Intel Virtualization, Intel HAXM, and running emulator.  Therefore, I wrote this post to show the complete guide.

Firstly, AMD and Intel uses different emulation.  In this post, it is mainly covering Intel CPU, and not AMD.

Following is the error when you run the program in emulator mode:
There will be 2 error messages as below:
Emulator: Process finished with exit code 1
Emulation: emulator: ERROR x86 emulation currently requires hardware acceleration!

There are several steps involve to set it up:
  1. Enable VT-x is supported by the Intel CPU.  If your CPU doesn't support it, then buy another CPU.  5 year old i3 supports VT-x, so you can get a used CPU for very cheap
  2. Enable Intel Virtualization in BIOS - I will show the step for ASUS motherboard.  Newer motherboard might have additional choice of VT-x in separate menu, while mine is just under 1 screen, and 1 setting
  3. Install & run Intel Processor Identification Utility - used to verify both BIOS and CPU are ready with above setting. Confirms "Intel Virtualization Technology" is ready (Yes)
  4. Install "Intel x86 Emulator Accelerator (HAXM installer)" from Android Studio
  5. Verify using above tool that Intel "VT support" and "NX support" are detected
  6. Test emulator

Step 1: Verify the Intel CPU Support Virtualization (VT-x)

If you are not sure whether your Intel CPU supported Virtualization Technology, look up this page from Intel and click on "Intel Core Processor" or choose other CPU model such as Celeron, Pentium, Xeon, Atom, etc:
https://ark.intel.com/#@Processors

For my Intel Core i7-2600K, following is the navigation path:
  1. Click on "Intel Core Processor"
  2. The next screen show generation 4 to 9, but mine is 2nd Generation, so I click on "Legacy Intel Core Processors" at the end of the list

  1. Click on i7-2600K link, and scroll down to section "Advanced Technologies"
  2. Ensure "Intel Virtualization Technology (VT-x)" shown Yes
The next step assume you have Intel CPU that supports VT-x.  Don't waste your time to proceed if your CPU doesn't support it.

Step 2: Enable Intel Virtualization in BIOS

Following is the screenshot of my ASUS P8Z68V-LE motherboard's BIOS.  It shown that "Intel Virtualization Technology" is enabled.  For my motherboard, I have to set it using following sequence in order to enable it:
  • Disabled it - set value to Disabled
  • Reboot into Windows
  • Reboot into BIOS
  • Enabled it - set value to Enabled
  • Reboot into Windows
This appeared to be a bug in the my BIOS to toggle Intel Virtualization, even its BIOS version is latest version

Step 3: Install Intel Processor Identification Utility

URL: https://downloadcenter.intel.com/download/7838/Intel-Processor-Identification-Utility-Windows-Version

Visit above Intel download page to download "Intel Processor Identification Utility" to confirm that the BIOS setting is in effect.  In Step 1, we already confirmed your CPU support Intel Virtualization, while Step 2 should enable BIOS to enable this feature.  So this utility will confirm both CPU & BIOS are set properly and you should see Intel Virtualization is enabled in this utility.

Once installed, run it by double clicking the icon
Acknowledges the license agreement, and it will run.  Click on 2nd tab to verify the setting.  You will see "Intel Virtualization Technology" = Yes
If it is "No" then repeat Step 2 to toggle the value in BIOS, or look in BIOS for other screen which contains other setting to enable VT-x

Do not proceed until this utility detected "Yes"

Step 4: Install "Intel x86 Emulator Accelerator (HAXM installer)" from Android Studio

At this point, all the hardware and firmware are setup and verified.   The next step is to install Intel HAXM from Android Studio.  You can download & install this utility from Intel homepage, which I won't cover.  My experience shown that Android Studio works every time to install/uninstall HAXM without issue, so manually install doesn't seem to be required

Go into SDK Manager from Tools pull down menu of Android Studio.  Depending on its version, the exact location will vary, but it is always under Tools pull down menu:


Click on 2nd tab called "SDK Tools" and scroll down to "Intel x86 Emulator Accelerator (HAXM installer)."  This utility will cancel its installation if it doesn't detect VT-x, such as BIOS is not enabled.  In my situation, my BIOS has a bug that needs to toggle 4 times to enabled VT-x, so even I selected the checkbox to install it, it will cancel its installation, and shown not selected in this screen.

Now, click no the checkbox next to it to install HAXM.

This will shown when it is starting to install

Installer started.  Waits for the last message to appear.  It must shown "Intel HAXM installed successfully!" or a failure of Intel Virtualization not enabled.  If failed, repeat Step 2 - 3

Once you closed above screen, the "Component Installer" screen will show it complete as well as finished.  Please take note of the SDK installation directory.  In my case, it is "D:\Language\Android\sdk\extras\intel\Hardware_Accelerated_Execution_Manager."  We will need to verify HAXM using a build-in utility in next step

Lastly, you will see the checkbox enabled for Intel x86 Emulator Accelerator as shown below

Step 5: Verify using haxm_check.exe tool that Intel "VT support" and "NX support" are detected

Using Windows Explorer, browse to the SDK directory.  In my case, it is in following directory
D:\Language\Android\sdk\extras\intel\Hardware_Accelerated_Execution_Manager


 Open PowerShell from here by right-click on this screen:
Run "haxm_check" as shown below.  You will see "yes" for:
  • VT support
  • NX support



If above is yes, then 90% of possibility that the BIOS setting is recognize by HAXM.  In my motherboard, even Intel Processor Identification Utility recognize it, but HAXM didn't.  I have to repeat Step 2 - 3 one more time for haxm_check to recognize it.

Back to Android Studio, to spawn AVD Manager to spawn the emulator to further verify it.  Click on pull down menu Tools to find AVD Manager.  It might be under different sub-menu depending on Android Studio version

Click on the play button next to the virtual device to spawn the emulator.

 If VT-x is property setup, then you should see a new phone picture appear

If you are getting the same error message again, then you will need to manually uninstall/re-install HAXM using following steps:
  1. Navigates to SDK dir: D:\Language\Android\sdk\extras\intel\Hardware_Accelerated_Execution_Manager
  2. Double click on intelhaxm-android.exe
  3. Click on "Remove" button to uninstall Intel HAXM

  1. Close it, and repeat Step 2
  2. Follow the wizard to install it
  3. If VT-x is not detected, then the installer will exit at this point.  So you will need to repeat Step 2-3 again
In my computer, I will have to perform this step even Intel Virtualization is setup & detected by following
  • BIOS
  • Intel Processor Identification Utility
  • haxm_check.exe utility
It seems that the HAXM installer uses different detection function than above 2 Intel utilities

Please give me donation if you find this guide is useful

No comments:

Post a Comment