WSL: Android emulator not starting anymore

Windows 10 21296 AMD 4800H

I don’t know whether this is related to WSL, Windows or Android emulator itself, but here’s what’s happening.

I used to run WSL2, Docker (WSL2) and Android Studio emulator side-by-side. Everything worked. Docker was up and running in WSL2. I could launch emulators from within Android Studio.

Now, the emulators stopped working. AVD Manager throws a The emulator process for AVD Pixel_4_API_30 was killed. error, without further information.

When I try to run it manually via the console, I get these errors:

.\emulator -avd Pixel_4_API_30

WHPX: Failed to get virtual processor registers, hr=c0350005
WHPX: Failed to emulate PortIO access with EmulatorReturnStatus: 64
WHPX: Failed to exec a virtual processor

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 32
  • Comments: 63 (1 by maintainers)

Most upvoted comments

I’m looking for a fix for this too, I’m using Windows 11 Pro - 21H2 22000.194 and AVD doesn’t work with Virtual Machine Platform enabled, but if I disable AVD works and WSL 2 don’t.

I’m think that’s valid to reopen the issue

Hey guys, I think the workaround is to turn off HyperV when Windows startup, maybe there is a conflict between HyperV and HAXM (I thought this problem is already resolved in the latest version of Android Studio?)

To do this, open Powershell as Admin -> bcdedit /set hypervisorlaunchtype off -> restart pc. By doing this, you will not be able to run wsl2 but android emulator will work. To turn HyperV back on, open Powershell as Admin -> bcdedit /set hypervisorlaunchtype auto -> restart pc.

Hopefully, there will be a solution for this problem since it’s pretty inconvenient to switch back and forth just to get the emulator working.

I found a solution from the Google issue tracker to make AVD work with Hyper-V enabled on my AMD CPU. https://issuetracker.google.com/issues/202188690#comment18

image

This requires compiling qemu, but I didn’t encounter problems while following the guide.

Binary files compiled by me: https://paste.c-net.org/BlatantEnjoying (a random site that can upload files, the word in the URL is meaningless). Extract to <ANDROID_SDK>/emulator/qemu/windows-x86_64.

Same error as @otocon, WHPX is not working for AVD in Windows 11, please reconsider opening the issue.

> 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\Zeswen\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: WHPX: Failed to setup partition, hr=c0350005
C:\Users\Zeswen\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: failed to initialize WHPX: Invalid argument

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.

@viet-quocnguyen This is not a workaround, since some folks (like me) rely on simultaneously running WSL2 and emulators. I.e. how else would you test a NodeJS API (running in WSL2) on a Flutter app, running in an Android TV emulator?

Thanks for reporting the issue, we have routed the report to the correct team and they are investigating a fix.

Can confirm, Windows 21327 fixes the issue.

Facing the same issue. Tried almost all ways I can find to make AVD and WSL2 work at the same time. In the end, it turned out to be totaly a futile attempt. Reopen this issue please.

System info:

  • AMD Ryzen 9
  • Windows 11 Pro 21H2 22000.282

Same issue, 21322 Dev

Same issue. Windows Insiders 21318

Is there any official statement regarding this issue?

Is there any fix in the latest Dev Channel Build 21327 ?

I have tested on my laptop (HP OMEN15, i7-10870H, RTX2060) that the build 21327 fixed the problem .

Likely. If it were a new feature request that would be one thing, but I’m hoping that because it’s something that USED to work a few weeks ago and has since been broken with an update, that’s it’s something that be corrected without too much headache.

Definitely! It used to work before Windows 21292 (iirc).

Same error as @otocon, WHPX is not working for AVD in Windows 11, please reconsider opening the issue.

> 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\Zeswen\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: WHPX: Failed to setup partition, hr=c0350005
C:\Users\Zeswen\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: failed to initialize WHPX: Invalid argument

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.

I thought this could do it for me too, but it’s so damn slow it’s not even usable on my machine - I mean, 20 minutes to launch, 30 seconds to register a click… No can do. The “main monitor” stuff just feels weird to me and of course doesn’t help at all in my case.

Which makes me wonder. Are we better off letting go of WSL2 and try to run our API in a Virtualbox or similar? Since it’s visibly a very low priority bug… Even lower for Ryzen users like me…

I have a related issue. WSL2 is working perfectly when I’m having Hyper-V activated. Then I’m trying to use Android Studio’s emulator and it just hangs, never launching the emulator. Now, if I deactivate Hyper-V entirely (in the windows features screen and through bcdedit /set hypervisorlaunchtype off) the emulator does launch perfectly, but of course WSL2 won’t work now… So, if I want to dev my api on WSL2 and run my app on an android emulator, I can’t? I have a Ryzen 5 processor.

Same problem. Brand new install. This time, what I did was… I installed Docker, works fine and runs. Installed Android Studio, works fine and runs. I can run both together fine. However, when I installed Debian (which uses WSL 2) now all of a sudden I can’t get the emulator to run.

Edit: I just figured this out. And it’s really annoying.

You must have the Android Emulator running on your MAIN monitor

After I did this, it works every time. Here it is running Android Studio, VirtualBox, Debian WSL-2, and Docker all at once. Once you get it to load, you can move it to other monitors by following the answer here: https://stackoverflow.com/questions/44708452/avd-crash-on-second-monitor

image

you are a legend this really fixed the issue don’t run the emulator on your second screen, only your main monitor.

I have a related issue. WSL2 is working perfectly when I’m having Hyper-V activated. Then I’m trying to use Android Studio’s emulator and it just hangs, never launching the emulator. Now, if I deactivate Hyper-V entirely (in the windows features screen and through bcdedit /set hypervisorlaunchtype off) the emulator does launch perfectly, but of course WSL2 won’t work now…

So, if I want to dev my api on WSL2 and run my app on an android emulator, I can’t?

I have a Ryzen 5 processor.

Same problem. Brand new install. This time, what I did was… I installed Docker, works fine and runs. Installed Android Studio, works fine and runs. I can run both together fine. However, when I installed Debian (which uses WSL 2) now all of a sudden I can’t get the emulator to run.

Edit: I just figured this out. And it’s really annoying.

You must have the Android Emulator running on your MAIN monitor

After I did this, it works every time. Here it is running Android Studio, VirtualBox, Debian WSL-2, and Docker all at once. Once you get it to load, you can move it to other monitors by following the answer here: https://stackoverflow.com/questions/44708452/avd-crash-on-second-monitor

image

Wondering has there been any update on this? It’s a pretty big blocker for me. I’m unable to disable Hyper-V since I rely on WSL2 for the development work that the emulator is using.

Thanks!

I think this issue is extremely low prioritized, since the percentage of users who run WSL2 and Android emulators simultanously is very low.

Same problem. it was broken by windows update 21292.1000

https://developercommunity.visualstudio.com/content/problem/1310877/unable-to-start-android-emulator.html

Windows 21301.1000

solved with .\emulator.exe -avd Medium_Phone_API_35 -feature -Vulkan

Having the same issue here.

  • AMD Ryzen 9
  • Windows 11 Pro 21H2 22000.258

Here’s a link to the Google issue tracking this: https://issuetracker.google.com/issues/202188690?pli=1

I’d be very curious to know just what changed to fix things.

@ALL WSL2 has it’s own feature known as VMM (Virtual Machine Management) that is required to be added in addition to the WSL feature for WSL2 to run. It is based on Hyper-V but does NOT require the Hyper-V feature to be enabled to run. The only reason to also enable Hyper-V is if you still wish to run VMs in Hyper-V or to use it’s commandline functionalities to “hack” WSL2 for stuff like virtual NICs as workarounds. Has anyone actually tested the emulator not working with only WSL2 enabled and NOT Hyper-V? I think it’s still likely to be broken but there’s a small chance it can still work until proven otherwise.

I tested all possible options of enabling/disabling Windows Features and it comes down to either have a working emulator, or a working WSL2/Docker, but not both. Maybe I still may have missed something, and someone can point to a workaround.

I have a related issue. WSL2 is working perfectly when I’m having Hyper-V activated. Then I’m trying to use Android Studio’s emulator and it just hangs, never launching the emulator. Now, if I deactivate Hyper-V entirely (in the windows features screen and through bcdedit /set hypervisorlaunchtype off) the emulator does launch perfectly, but of course WSL2 won’t work now…

So, if I want to dev my api on WSL2 and run my app on an android emulator, I can’t?

I have a Ryzen 5 processor.