Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Emulator is not working on Windows 11 using WHPX

I have Windows 11 on my system.
The system specifiction:

  • Edition: Windows 11 Home Single Language
  • Update: 21H2
  • Installed on: ‎06-‎07-‎2021
  • OS build: 22000.65
  • Experience: Windows Feature Experience Pack 421.17400.45.3

I have fresh installed Android Studio. Now I want to run the emulator without Intel HAXM as I want to run it alongside wsl2.

So in my optional feature, these two features are enabled

  1. Windows HyperVisor Platform
  2. Virtual Machine Platform

But while running the emulator I'm getting this error:

❯ .\emulator.exe -avd Pixel_3a_API_30
emulator: Android emulator version 30.7.5.0 (build_id 7491168) (CL:N/A)
handleCpuAcceleration: feature check for hvf
added library vulkan-1.dll
C:\Users....\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: WHPX: Failed to setup partition, hr=c0350005
C:\Users....\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: failed to initialize WHPX: Invalid argument

Anyone got suggestions, how to resolve this issue.

like image 431
Supriyo Mahanta Avatar asked Jul 14 '21 06:07

Supriyo Mahanta


People also ask

Can Android Studio run on Windows 11?

The System Requirements for Android Studio on Windows Your PC must meet the following requirements to run Android Studio efficiently: 64-bit Microsoft Windows OS 8/10/11. 1280 x 800 minimum screen resolution. x86_64 CPU architecture; 2nd generation Intel Core or newer; or AMD CPU with Hypervisor support.

Does HAXM work on Windows 11?

Your computer must be running Windows 11 or Windows 10 Version 1909 or later.

Why is my Android Studio emulator not working?

If the Android Emulator does not start properly, this problem is often caused by problems with HAXM. HAXM issues are often the result of conflicts with other virtualization technologies, incorrect settings, or an out-of-date HAXM driver. Try reinstalling the HAXM driver, using the steps detailed in Installing HAXM.

How do I install Intel HAXM on Windows 11?

Installing from Android SDK Manager Go to Android SDK Manager (Tools -> SDK Manager) and select SDK Tools. You will find the Intel x86 Emulator Accelerator HAXM installer listed here. Select it and click on OK.


Video Answer


4 Answers

Final Update:

As stated by Георги Ангелов:

The latest version of Android Emulator - 31.1.2 is fixing the issue. Update through SDK Manager. Released 11/11/2021.


Update:

As stated in Mark Wood-Patrick answer, the emulator hasn't been updated yet but you can download the new emulator binaries with the fix!

From https://issuetracker.google.com/issues/202188690#comment48

windows: https://dl.google.com/android/repository/emulator-windows_x64-7869535.zip
linux: https://dl.google.com/android/repository/emulator-linux_x64-7869535.zip
macosx: https://dl.google.com/android/repository/emulator-darwin_x64-7869535.zip


WHPX as of now is not working with Windows 11, I will update this answer when it gets fixed.

There are two possible workarounds:

Disable Hyper-V (Keep in mind WSL2 or any VM won't work without this)

To disable Hyper-V you must follow these steps:

  1. Open Turn Windows features on or off.
  2. Uncheck Hyper-V and Windows Hypervisor platform (it may be required to uncheck Windows Sandbox).
  3. Open Android Studio and SDK Manager.
  4. In SDK tools, install Android Emulator Hypervisor Driver for AMD Processors (installer).

Open the emulator with no acceleration

  1. Open a terminal.
  2. Enter cd C:\Users\User\AppData\Local\Android\Sdk\emulator\ with your user.
  3. Enter .\emulator.exe -avd Pixel_4a_API_30 -accel off with your AVD device name.
like image 175
Zeswen Avatar answered Oct 08 '22 05:10

Zeswen


The latest version of Android Emulator - 31.1.2 is fixing the issue. Update through SDK Manager. Released 11/11/2021.

like image 34
Георги Ангелов Avatar answered Oct 08 '22 05:10

Георги Ангелов


You must disable "Virtual Machine Platform" too, not just Hyper-V enter image description here

like image 39
georgeci Avatar answered Oct 08 '22 04:10

georgeci


Current solution until Google releases a new version of the emulator:

Download the binaries from https://issuetracker.google.com/issues/202188690#comment27 and extract them into your emulator directory, replacing the qemu binaries.

like image 5
surban Avatar answered Oct 08 '22 05:10

surban