android-studioandroid-emulatorandroid-virtual-devicehypervisorwindows-11

Android Studio Emulator is not working on Windows 11 using WHPX


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

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.


Solution

  • 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.