skip to Main Content

Setup:

  • Windows 11 Home 21H2 22000.132
  • AMD Ryzen 5900X
  • WSL2
  • Android studio lastest build (also tried with latest beta)

Problem:
As soon as I install WSL2, the emulator stops working. It’s giving the following error message:

C:UsersgustaAppDataLocalAndroidSdkemulator>emulator.exe -avd Android_TV_1080p_API_300
emulator: Android emulator version 30.8.4.0 (build_id 7600983) (CL:N/A)
handleCpuAcceleration: feature check for hvf
added library vulkan-1.dll
Failed to open /qemu.conf, err: 2
C:UsersgustaAppDataLocalAndroidSdkemulatorqemuwindows-x86_64qemu-system-x86_64.exe: WHPX: Failed to setup partition, hr=c0350005
C:UsersgustaAppDataLocalAndroidSdkemulatorqemuwindows-x86_64qemu-system-x86_64.exe: failed to initialize WHPX: Invalid argument

Using WSL2 at the same time as the android emulator was working before on an Intel i7 4770k processor, but stopped working after a processor upgrade to a AMD Ryzen 5900x and fresh install of Windows 11.

For clarification: I’m not trying to run the emulator from WSL2, I’m trying to run it from Android Studio. When trying to start it from Android Studio it never launches, when trying to run it from the Windows Command Line I get the above error.

The "Failed to open /qemu.conf" is possible to solve by creating that file manually, as explained by this answer. That however doesn’t fix the two later errors with WHPX.

I’ve followed the official instructions on this page (Following the AMD with Hyper-V option WHPX). I think the problem has to do with Hyper-V running which WSL2 is using if I’m not misstaken. But according to the above link it should be possible to run the emulator at the same time as Hyper-V using WHPX. I’ve also tried using the Android Emulator Hypervisor Driver for AMD processors, which is giving me the exact same result.

Activated Windows features:

Windows features

Thankful for any help, and please tell me if I need to add more information

6

Answers


  1. Chosen as BEST ANSWER

    I finally got this working using this fix (answer number 48). Seems like a valid workaround until windows fixes this issue. I downloaded the compiled version for windows and moved it to my emulator path C:Users<username>AppDataLocalAndroidSdkemulator. Seems to be versions available for linux and mac as well but I haven't tested those.


  2. Newer Answer

    I found and tested in shorter toggle mechanism.

    The configuration for Windows Feature:

    • Windows Subsystem for Linux is installed.
    • Windows Hypervisor Platform is installed.
    • Hyper-V is installed.

    If you need the Emulator, you only need to turn off Hypervisor + Restart. Run: bcdedit /set hypervisorlaunchtype off

    If you need the Docker back, you can run the hypervisor hence disabling Emulator. Run: bcdedit /set hypervisorlaunchtype auto

    You need to restart after setting Hypervisor

    You cannot run both at the same time. Another forum worth checking in How about running docker? in my older answer below.


    Older Answer

    I think I solved this issue, tested to run from CMD / Android Studio and ran perfectly as before installing WSL. There are several step we go:


    Configuring Windows Feature:

    1. Removed Windows Subsystem for Linux
    2. Removed Windows Hypervisor Platform
    3. Removed Hyper-V

    Here is my current setup:

    Windows Feature


    Reverting AVD setup

    I know after removing there are some odds because the AVD still get the same error as before and expected to get into WSL. I stumbled and found something when ran:

    C:Users[NAME]AppDataLocalAndroidSdkemulatoremulator-check.exe accel

    That command will check the current accel. It explains that the Hypervisor need to be set off and give specific help:
    run bcdedit /set hypervisorlaunchtype off.

    After running the bcdedit, I restarted and all is reverted. Now I can run emulator both from CMD and Android Studio perfectly.


    How about running docker?

    Sad truth, yeah you cannot run both pararel. There are several workaround in this forum:

    How can I run both Docker and Android Studio Emulator on Windows?

    Several option ranging from changing emulator, add & remove docker when in need using above step, created nested vm, etc. My personal choice right now is using another Emulator for the time being and removed docker for the latter.


    Login or Signup to reply.
  3. This problem only occurs with AMD processors, I have two systems both with WSL2 and Docker running on the latest Windows 11 (Insider Beta) build. One with an AMD Ryzen 5950 and one with an Intel i7-8086K.
    On the Intel system the emulator runs fine with hardware acceleration together with WSL2 and Docker.

    On the AMD I run into the same error when running the emulator with hardware acceleration. In the Windows 10 Insider builds before Windows 11 it still worked.

    A very similar problem was introduced before in Windows 10 build 10.0.21292
    and later fixed in build 21327. (https://github.com/microsoft/WSL/issues/6471) But this problem affected both Intel and AMD.

    I haven’t tried to turn off the AMD fTPM yet, as this is the only other change apart from updating Windows 10 Insider (dev ring) to Windows 11.

    The Android Emulator Hypervisor Driver for AMD processors only works when the Windows Hypervisor is disabled, it’s not used for WHPX.

    The Windows Feedback is full of reports of this problem, please upvote them.

    Login or Signup to reply.
  4. Android Studio emulator doesn’t support run Hyper-V on Windows 11, we can disable Hyper-V to run but if we do that applications which require Hyper-V to run like WSL2, Docker then fail to run.

    While waiting Google update Android Studio emulator support Hyper-V we have a workaround solution to run both by using another emulator which support Hyper-V like Bluestack 5 version "Nougat 64 bit (Supports Hyper-V)" at the link below
    https://www.bluestacks.com/download.html

    Login or Signup to reply.
  5. If you did all of those steps and still you are facing that emulator termination issue, then please upgrade or download your graphic card drivers and install it. After I installing Windows 11 this issue happened to my android studio emulator. Lot of steps I followed but nothing work. after that I checked my Graphic card drivers and install it. Now emulator working fine…

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search