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)
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
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.
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:
Turn Windows features on or off.Hyper-VandWindows Hypervisor platform(it may be required to uncheckWindows Sandbox).Android Emulator Hypervisor Driver for AMD Processors (installer).Open the emulator with no acceleration
cd C:\Users\User\AppData\Local\Android\Sdk\emulator\with your user..\emulator.exe -avd Pixel_4a_API_30 -accel offwith 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.
@LefanTan The change is from https://issuetracker.google.com/issues/202188690#comment18, I only do the compiling work.
Commenting out this line
whpx_disable_xsave(whpx);(https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/target/i386/whpx-all.c#1768).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:
Same issue, 21322 Dev
Same issue. Windows Insiders 21318
Is there any official statement regarding this issue?
I have tested on my laptop (HP OMEN15, i7-10870H, RTX2060) that the build 21327 fixed the problem .
Definitely! It used to work before Windows 21292 (iirc).
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…
you are a legend this really fixed the issue don’t run the emulator on your second screen, only your main monitor.
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
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 -VulkanHaving the same issue here.
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.
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.