Score:0

Why can I not run android emulator on wsl2 on Ubuntu 20.04.2?

in flag

I am using a HP 470 G8 laptop with an 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz processor and I have recently installed Ubuntu 20.04.2 within WSL2 on my Windows 10 Professional. After installing Android Studio on Ubuntu, I tried to set Android AVD Manager, but I get this error:

Your CPU does not support required features VT-x or SVM

Here is an image of my problem:

Virtual Device Configuration

I have enabled VT-x in BIOS but I still get the same error and can not start the Android emulator. I also disabled the Hyper-V feature in Windows and restarted the laptop, but still get the same error.

So how can I run the Android Emulator even when the Android Studio system says that my CPU does not support VT-x, which is not the truth?

ChanganAuto avatar
us flag
It's probably complaining because WSL2 already uses the virtualization support so you may well be looking at a situation that is similar to nested VMs.
Dezo avatar
in flag
When I enter "sudo kvm-ok" command in the Ubuntu command line I get the message that my CPU does not support KVM (kernel-based Virtual Machine) extensions so I suppose that my CPU is still not enough supported in Canonical's Ubuntu 20.04
ChanganAuto avatar
us flag
No, you understood nothing from the above comment. The problem isn't the CPU, it's WSL2. It won' t be a problem with a normal Ubuntu installation. The problem is trying to run a VM inside a VM. Why aren't you using Android Studio directly in Windows? If you want to use in Ubuntu then install Ubuntu in dual-boot.
Dezo avatar
in flag
Yeah, dual boot seems more suitable because nothing works fine over wsl2
ChanganAuto avatar
us flag
Again no, many or actually most things work fine in WSL2. The problem is users with unrealistic expectations.
Dezo avatar
in flag
I installed windows 10 and Linux Fedora as dual boot on my laptop and everything works fine. I noticed that on my linux OS the android studio and the emulator work flawlessly. I also do not have any problems with sound as I had using the Ubuntu on wsl2. So I think the dual boot is still better way to run 2 OS on one computer than use wsl2.
Score:2
vn flag

As mentioned in the comments, you would need Nested Virtualization for this, since you are attempting to run a VM inside another vm. Nested virtualization is only supported in the latest (currently unreleased) WSL available if you are on Windows Insider.

While I can't guarantee that this will work for Android Studio, at the very least you need to be running Windows 11 Beta or a recent Windows 10 Dev Channel build. This is not necessarily recommended as a daily driver at this point.

According to the wsl.conf doc, the nestedVirtualization option defaults to true in these builds. You can always try forcing it to true by creating a /etc/wsl.conf file with:

wsl2]
nestedVirtualization = true

... although again, it shouldn't be necessary.

According to this doc you may even need to compile your own kernel, but that information is about a year old, so the latest WSL kernels may now include that support as well.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.