Skip to content Skip to sidebar Skip to footer

Running Wsl2 And Android Studio At The Same Time With A Ryzen Processor

I would like to run WSL2 with my api in it, and an Android emulator to run my app so I can test said api. WSL2 is working perfectly when I'm having Hyper-V activated. Then I'm tryi

Solution 1:

I was able to find way around it. I'm running Windows 11 Pro, Update 21H2, OS build 22000.51, AMD.

Here is Google documentation how to setup emulator for AMD processors. It requires Hyper-V and WHPX to be disabled. And that does not go in pair with running WSL2.

My setup is:

  • Android Studio and IntelliJ running under Windows
  • Docker, DBs and other services running under Ubuntu (WSL2)

What I did:

  1. Enable Hyper-V and WHPX.
  2. Added new Android VM in Hyper-V Manager like that
  3. Find Android VM IP address (I did so by going to running Android wi-fi options) and use adb connect <ip goes here>:5555
  4. If connected properly, it should appear in Android Studio.

I tried to adb connect to the Android from Ubuntu, but it does not work out of the box. Should be doable with some WSL2 > Host redirects, but I currently do not need it and did not research it any further.

Last thing that bugged me was default Android VM resolution (looks like tablet in horizontal orientation). It is possible to adjust it like that.

We probably need to wait for Google to come up with emulator that uses the same emulation type as WSL2.

Things that do not work/are missing (or I do not know how to do it):

  • cannot change screen orientation on the fly
  • software keyboard is not showing up when typing (problem when you need to test your UI with it)
  • no GPU acceleration in Hyper-V (Microsoft disabled it due to secuirty reasons (?) but there seems to be a way to enable it, have not tried it, for my needs default performance is fine)

Solution 2:

So, someone gave a great answer on the issue tracker!

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

Basically, as he says, It's being caused by the XSAVE disable code in the WHPX API integration -- target/i386/whpx-all.c -- commenting out this line appears to make it work: https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/target/i386/whpx-all.c#1768

In the issuetracker, another user has posted already compiled exe files, if anyone needs it. For me it fixed everything, the emulator is now working perfectly properly.

Post a Comment for "Running Wsl2 And Android Studio At The Same Time With A Ryzen Processor"