Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android emulator not starting anymore #6471

Closed
ad-on-is opened this issue Jan 26, 2021 · 62 comments
Closed

Android emulator not starting anymore #6471

ad-on-is opened this issue Jan 26, 2021 · 62 comments
Labels
external Issue exists outside of WSL components hypervisor-platform

Comments

@ad-on-is
Copy link

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
@ahmedalnuaimi
Copy link

Neither on Windows itself nor on WSL. It has been like this for about two weeks.

@viet-quocnguyen
Copy link

I have the same problem!

@dbanda
Copy link

dbanda commented Jan 31, 2021

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

@viet-quocnguyen
Copy link

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.

@ad-on-is
Copy link
Author

@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?

@viet-quocnguyen
Copy link

@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?

@ad-on-is I see... It will be a pain but maybe you could try to run the APIs on windows instead? Just a temporary set up so you could get work done I guess.

@ad-on-is
Copy link
Author

ad-on-is commented Feb 1, 2021

@viet-quocnguyen Sure, there are multiple temporary solutions, like switching to VirtualBox.

@ad-on-is
Copy link
Author

ad-on-is commented Feb 2, 2021

Is there any official statement regarding this issue?

@benhillis
Copy link
Member

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

@benhillis benhillis added the external Issue exists outside of WSL components label Feb 10, 2021
@alexeagleson
Copy link

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!

@WSLUser
Copy link

WSLUser commented Feb 25, 2021

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

@ad-on-is
Copy link
Author

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.

@ad-on-is
Copy link
Author

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

@alexeagleson
Copy link

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.

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.

@ad-on-is
Copy link
Author

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

@murbanowicz
Copy link

I have same issue.

Ryzen 3900X
Windows Insiders 21322.

@manoj398
Copy link

Same issue. Windows Insiders 21318

@MZO9400
Copy link

MZO9400 commented Feb 27, 2021

Same issue, 21322 Dev

@patfla
Copy link

patfla commented Mar 1, 2021

I wonder if backing up from Dev to Beta will give me a version where the emulator will work again? It'd be helpful if the "Pick your Insider settings" screen would dynamically tell you just what version each corresponds to.

@patfla
Copy link

patfla commented Mar 1, 2021

This page does give versions for Dev, Beta, and Release Preview at the bottom:

https://insider.windows.com/en-us/

@SmartPolarBear
Copy link

SmartPolarBear commented Mar 4, 2021

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 .

@ad-on-is
Copy link
Author

ad-on-is commented Mar 4, 2021

Can confirm, Windows 21327 fixes the issue.

@ad-on-is ad-on-is closed this as completed Mar 4, 2021
@manoj398
Copy link

manoj398 commented Mar 4, 2021

Can confirm, Windows 21327 fixes the issue.

Can confirm

@zachary-russell
Copy link

zachary-russell commented Mar 4, 2021 via email

@patfla
Copy link

patfla commented Mar 4, 2021

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

@dominicm00
Copy link

21327 fixed the issue for me on AMD/Nvidia platform

@viet-quocnguyen
Copy link

21327 fixed the issue. Thanks guys!

@otocon
Copy link

otocon commented Jul 7, 2021

I found a temporary workaround by running Android Emulator with Hyper-V Manager. Description here.

EDIT
That's the error I get when trying to run emulator in the old way on AMD machine and having WSL2 running as well:
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\lukas\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: WHPX: Failed to setup partition, hr=c0350005
C:\Users\lukas\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: failed to initialize WHPX: Invalid argument

@Zeswen
Copy link

Zeswen commented Aug 26, 2021

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.

@Nouradawy
Copy link

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.

@JerryBels
Copy link

Doesn't help for me.

@JerryBels
Copy link

JerryBels commented Sep 15, 2021

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

@Jictyvoo
Copy link

Jictyvoo commented Sep 22, 2021

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

@jmSfernandes
Copy link

Im facing the same issue, Windows 11 Home 21H2 22000.258.
My Emulator was working just fine prior to updating to windows 11.
Please reopen the issue.

@flipswitchingmonkey
Copy link

There is a workaround, kind of, until this is (hopefully soon, but seeing how there are all kinds of problems with Ryzen (scheduler...) I'm not holding my breath...) fixed.

I got the emulator working at good speed (and reasonably stable, so far) by installing Android Studio inside WSL2, and by installing the vGPU drivers for WSLg, AND by updating the Mesa drivers to the latest version. Like so:

wslg

see https://github.com/microsoft/wslg
in Powershell:

wsl --update

in WSL shell

sudo apt update
sudo apt upgrade

Install vGPU graphics drivers (see links on wslg page)

Install latest Mesa drivers

see https://itsfoss.com/install-mesa-ubuntu/

sudo add-apt-repository ppa:kisak/kisak-mesa
sudo apt update
sudo apt upgrade

Install Android Studio

sudo apt install openjdk-11-jdk
sudo add-apt-repository ppa:maarten-fonville/android-studio
sudo apt install android-studio

I'm using fish so some paths may not be set:

fish_add_path ~/Android/Sdk/platform-tools/
fish_add_path ~/Android/Sdk/emulator/

also add

set -x ANDROID_SDK_ROOT "/home/myuser/Android/Sdk"

to your ~/.config/fish/config.fish

Obviously this may vary slightly for bash etc.

You probably also need to fiddle with the /dev/kvm permissions since they default to root only.

It also means that you have to do your coding inside WSL.

@alokraj68
Copy link

alokraj68 commented Oct 15, 2021

This bug needs to be reopened. can confirm there is no way to run an emulator with any of the above in Windows 11 with hyper v.
By turning off Hyper v, version 29 Emulator is running.

@aajahid
Copy link

aajahid commented Oct 17, 2021

Damn it! Wasted two days on this! Now I have to downgrade to window 10 and setup whole thing once again :(

@DanielCarmingham
Copy link

I've tracked this problem down to an issue with the Android Emulator WHPX (Windows Hypervisor Platform) support. (Or a breaking change in the WHPX APIs in Windows 11)

It does not appear to be related to WSL other than that by enabling WSL you would also need to enable WHPX to have hardware acceleration of the Android Emulator.

I've built the Android Emulator from source with some very small changes to the WHPX integration and in my (admittedly very basic) testing, it appears to function correctly.

For what it's worth, I am on an Intel i7-1185g7 CPU and it worked fine prior to the Windows 11 upgrade.

@alokraj68
Copy link

I am getting this issue in AMD Ryzen 7. Also, this issue is more there only in AMD chipset and not in windows. I am using an i7 7700HQ and it works flawlessly there.

@HazyFish
Copy link

HazyFish commented Oct 19, 2021

Reproduced on i7-1165G7 with a clean install of Android Studio on Windows 11 (22000.258).

@Hkmu
Copy link

Hkmu commented Oct 19, 2021

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

@hanskokx
Copy link

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

@RikkaW
Copy link

RikkaW commented Oct 23, 2021

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.

@LefanTan
Copy link

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. Extract to <ANDROID_SDK>/emulator/qemu/windows-x86_64.

You actually made it work! I copied the binary files to <ANDROID_SDK>/emulator/qemu/windows-x86_64, and my emulator launched successfully with Docker running. What changes did you make to the binary files if I may ask?

Thanks btw.

@RikkaW
Copy link

RikkaW commented Oct 24, 2021

@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).

@jmSfernandes
Copy link

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. Extract to <ANDROID_SDK>/emulator/qemu/windows-x86_64.

Nice Job. It worked for me as well.
Windows 11 22000.282 and Amd Ryzen 9 5900HS

@carellano
Copy link

Encontré una solución del rastreador de problemas de Google para hacer que AVD funcione con Hyper-V habilitado en mi CPU AMD. https://issuetracker.google.com/issues/202188690#comment18

imagen

Esto requiere compilar qemu, pero no encontré problemas al seguir la guía .

Archivos binarios compilados por mí: https://paste.c-net.org/BlatantEnjoying . Extraer a <ANDROID_SDK>/emulator/qemu/windows-x86_64.

it worked for me on my zephyrus laptop, AMD Ryzen 9 5900HS

Edition Windows 11 Pro Insider Preview
Version Dev
Installed on 10/27/2021
OS build 22489.1000
Experience Windows Feature Experience Pack 1000.22489.1000.0

@hanskokx
Copy link

hanskokx commented Nov 1, 2021

I found a solution from the Google issue tracker to make AVD work with Hyper-V enabled on my AMD CPU. 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: paste.c-net.org/BlatantEnjoying. Extract to <ANDROID_SDK>/emulator/qemu/windows-x86_64.

Confirmed working. Thank you!

@moodstubos
Copy link

@RikkaW Thank you sooooooo much!

@hanskokx
Copy link

hanskokx commented Nov 2, 2021 via email

@lepskiy
Copy link

lepskiy commented Nov 3, 2021

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. Extract to <ANDROID_SDK>/emulator/qemu/windows-x86_64.

I replaced qemu files from the archive to <ANDROID_SDK>/emulator/qemu/windows-x86_64 as you said but have another error now:

Faulting application name: qemu-system-x86_64.exe, version: 0.0.0.0, time stamp: 0x6173cab6
Faulting module name: libOpenglRender.dll, version: 0.0.0.0, time stamp: 0x61057360
Exception code: 0xc0000005

Before the replacement the error was:

Faulting application name: qemu-system-x86_64.exe, version: 0.0.0.0, time stamp: 0x61057379
Faulting module name: MSVCP140.dll, version: 14.29.30135.0, time stamp: 0x612d915a
Exception code: 0xc0000005

My CPU and Android Emulator configiguration is:
AMD Ryzen 9 5900HS with Radeon Graphics.
Android emulator version 30.8.4.0 (build_id 7600983) (CL:N/A)
android-info.txt: Emulator: version-sysimage-git_pi-dev-sdk_gphone_x86_64-userdebug=4833817

@NPadrutt
Copy link

NPadrutt commented Nov 20, 2021

For me that gives me now this error, which persists even when I set the gpu.mode to off.
image

@grinder15
Copy link

grinder15 commented Apr 28, 2022

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

I've experience this today after installing WSL on Windows 11, Just refer to this comment and will save you from headache. I spent 5 hours screaming in agony without knowing Android emulator will not work if you have WSL installed on a Ryzen setup.

I really agree, we need to reopen this issue.

@mikehardy
Copy link

This seems to indicate AMD + win11 + Hyper-V (that is, WSL2) can work now https://issuetracker.google.com/issues/202188690

@scrubbybetter
Copy link

Can confirm, Windows 21327 fixes the issue.

Can confirm

What is windows 21327?
I have same issue but I haven't resolved yet.
Let me know more details.

@alexanderbkl
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Issue exists outside of WSL components hypervisor-platform
Projects
None yet
Development

No branches or pull requests