简体   繁体   中英

Android Studio Emulator is not working on Windows 11 using WHPX

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

  • Edition: Windows 11 Home Single Language
  • Update: 21H2
  • Installed on: 06-07-2021
  • OS build: 22000.65
  • Experience: Windows Feature Experience Pack 421.17400.45.3

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.

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.

You must disable "Virtual Machine Platform" too, not just Hyper-V 在此处输入图片说明

weird for me. two windows machines. both with fresh clean iso install of latest windows 11 builds (tried both dev and beta channels on both machines).

the i9-9900KF desktop will run android emulator using whpx acceleration, the XPS13 i7-1185G7 fails

re-installed windows 10 on the XPS13 and as expected the acceleration works....

i give up

It's possible to run the emulator from the WSL2 side and it's what I ended up doing. You can install the GUI version of Android Studio in WSL2 and from there create the emulator as usual.

How to run GUI apps in WSL2 if it's not working already:https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps

Not an answer to the original problem but a workaround for the time being.

这在谷歌被跟踪为问题https://issuetracker.google.com/issues/202188690

This works for me with an intel I7 11gen processor on latest version of windows 11 pro, Open Turn Windows features on or off Uncheck Hyper-V , Virtual Machine Platform , Windows Hypervisor Platform , Windows Sandbox and close Memory integrity (switch from on to off) from the Windows security Core isolation feature, after that you have to restart your device and install new AVD in your android studio and it will work fine.

Proof

I have been looking for a solution for a long time, because my Surface Pro 8 came with Windows 11 and I didn't wanted to switch back to Windows 10. But at the moment there seems to be no really good solution, which made me switch back to Windows 10 for now. Here everything works again. :)

Current solution until Google releases a new version of the emulator:

Download the binaries from https://issuetracker.google.com/issues/202188690#comment27 and extract them into your emulator directory, replacing the qemu binaries.

The latest version of Android Emulator - 31.1.2 is fixing the issue. Update through SDK Manager. Released 11/11/2021.

There is a fix for this issue see:

https://issuetracker.google.com/issues/202188690#comment45

Can I get more details on how you ran the emulator on wsl2 when I ran it the window came up but nothing was displayed. I am able to run nautilus and android studio on wsl2 without issue. I need to be able to run with hyper-v enabled

I can confirm this solved my issues with the emulator and Windows 11. Thanks for the work and effort to help identify my issues. The community is very strong and collaborative.

In the windows 11 Version 22H2 OS Build 22581.200: Goto Windows Security --> Device Security --> Core Isolation --> Memory Integrity (Turn this to Off)

I have a AMD Ryzen 9 CPU and upgraded to Windows 11 Pro. I've tried enabling and disabling both windows features (Hyper-V and Windows Hypervisor Platform). Android emulator just crashes (not responding). Also tried with and without the AMD driver.

System info CMD shows - Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed.

Any ideas?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM