How to configure KVM for Android Studio on Ubuntu? - linux

No matter how I configure my system, Android Studio shows the "We have detected that your system can run the android emulator in an accelerated performance mode. Linuxed-based systems support virtual machine acceleration through the KVM. Search for install instructions for your particular Linux configuration hat KVM is enabled for faster Android emulator performance."
egrep -c '(vmx|svm)' /proc/cpuinfo gives 8
kvm-ok gives INFO: /dev/kvm exists
KVM acceleration can be used
grep kvm /etc/group gives kvm:x:108:currentLoggedInUser
How should I configure KVM correct on Ubuntu 19.10? And how could I tell if Android Studio is running the VM using KVM?
Thanks.

i had same issue, but the other way around. To make it work, first make sure you've enabled virtualization in the BIOS and added your username in libvirt.
Click cancel on the screen that shows Android KVM
Android Studio will offer you to two options. Choose the one "don't start the setup wizard" (not the recommended one), so it will take you to the welcome screen.
Start a new project as usual and Android Studio will say couldn't find the SDK.
Choose the libraries and emulators to download and the rest is the same as usual.

Related

Cannot install Android Emulator Hypervisor Driver for AMD Processors (installer)

Disabled HyperV via GUI as above.
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
Then made sure via powershell via above.
Yet when running emulator-check.exe hyper-v:
hyper-v:
2
Hyper-V is enabled
hyper-v
I assume this is the issue. Virtualization is enabled. I have tried manually installing batch file (not in android studio). I have tried disabling Virtual Machine Platform and Windows Hypervisor Platform to install and that also didn't work (re-enabled after). CPU is AMD Ryzen 5 5625U with Radeon Graphics. Android Studio and the command were done with admin.
1st enable virtualization and hyper-v from your motherboard BIOS settings.
Then from the GUI enable the following:
Hyper-V
Virtual Machine Platform
Windows Hypervisor Platform
And after that restart your windows machine.
What fixed this, was turning Virtualization OFF in the BIOS and then ON again. After doing this mulator-check.exe hyper-v showed hyper-v to be not installed, which is the expected output. I was then able to install the driver in Android Studio as usual.

Android emulator /dev/kvm not found?

I am using fedora distro.
I went to create android emulator in android studio, but i got that /dev/kvm not found!
I tried to install kvm but still same.
Any one can help me ?
You need to enable KVM, from the BIOS by pressing F1 key before the system boot. Next, go to the Security tab and enable Intel Virtualization Technology and Intel VT-d Feature. Save the new settings by pressing F10. Finally, exit and restart your computer.

Unable to install Android Emulator Hypervisor Driver for AMD Processor

I am unable to install Android Emulator Hypervisor Driver for AMD Processor.
It is to be noted that virtualization is enabled.
Emulator Process for AVD was killed shown while running the code in Visual Studio while trying to install the Hypervisor Driver in Android Studio.
Error is also shown in Android Studio while installing the Hypervisor Driver:
What to do now? Thanks.
If you are using AVAST antivirus, It will not work .. So open Avast antivirus UI and go to Menu / Setting / troubleshooting and clear the tick on (( Enable hardware-assisted virtualization )) and restart. It will be installed.
First you should try to see if you have Hyper-V enabled. In most cases, the newer computers use it for hardware acceleration but it doesn't share with other virtualization apps, so to run this on an AMD or Intel VT-x first check if you have Hyper-V installed (go to your control panel, then in Programs and Features window, click “Turn Windows features on or off.” then look for Hyper-V and clear the checkbox then click OK.
If that doesn't work check your BIOS permissions, you can go to advanced CPU configuration or chipset and
find the "Intel Virtualization Technology", enable this option,
or
on AMD enable the SVM
then Save and Exit.
If you are using AVAST antivirus, It will not work .. So open Avast antivirus UI and go to Menu / Setting / troubleshooting and clear the tick on (( Enable hardware-assisted virtualization )) and restart. It will be installed.
This method by Tamer works for me but you have to restart your computer for it to be effective.
I had the same challenge when trying to add Bluestacks as an emulator in Android Studio and this was my solution.
Open PowerShell as Admin and do this command:
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
A restart should follow and all should be fine.
I'm not sure why you tried installing an AMD Virtualization driver for your Intel-CPU. As other people already suggested, try to install the Intel-Driver instead.
The installation probably failed because the program detected your not using an amd-cpu, so there's no point in installing it.

Using kvm with WSL (Trying to run Android emulator using WSL)

I am running Android Studio from WSL. When I try to use the emulator I get "/dev/kvm" not found. I have installed kvm and I have confirmed that vt-x emulation is enabled in my BIOS.
Is it possible to use kvm with WSL (Ubuntu)?
KVM only runs on an actual Linux kernel, not Windows Subsystem for Linux (which runs on a thin Linux emulation layer over the Windows kernel).
You can either run Android Studio on Linux natively, or use the Windows version of Android Studio (on Windows, only HAXM is supported).

Android Studio KVM Setting?

Put in KVM (Kernel-based Virtual Machine) into my 64 bit Ubuntu 14.04 LTS per:
https://help.ubuntu.com/community/KVM/Installation
In the terminal:
kvm-ok INFO: /dev/kvm exists KVM acceleration can be used
OK so the KVM is in.
When I run the Android Emulator there is no change from the way the Emulator ran before I put in the KVM.
I've looked in to the various settings within Android Studio, and I found nothing obvious about KVM.
Does Android Studio have a setting somewhere to enable KVM?
Android Studio 1.5 and 2.0 do not have such option any more.
Update: that is because the team has made KVM mandatory. And see comments from Google employees claiming that their new 2.0 emulator is also KVM-based.
Alright, so when you see the message (on Android Studio v2 and higher):
KVM is required to run this AVD.
/dev/kvm device: permission denied
Grant current user access to dev/kvm
What you can do (manually, since I haven't found anything in Android Studio) to fix this is:
Add your Linux user into the kvm group: sudo adduser your_linux_user kvm
If the group doesn't exist, download this package sudo apt install qemu-kvm and try to add your user again into the kvm group.
When the user has successfully been added into the KVM group, logout or restart and try opening Android Studio again.
This setting works totally fine in Ubuntu 18.04/18.10, but it should work in other distros as well.
You can do this:
Click on Run -> Edit Configurations and go to the Emulator tab
You can add it on "additional commandline options":
-qemu -enable-kvm
I'm not sure if there is also a GUI option somewhere though, or how to check if it is working or not.
I'd test the x86 image to see if it works any faster.
Downgrade to Android Studio 1.4 (delete Android Studio 1.5 installation, download zip from http://tools.android.com/download/studio/builds/1-4-0, follow installation instructions).
Follow Stuart Axon's instructions above.
Gabor as far as I can tell is correct (and addresses the OP's question) - the option to use this acceleration by starting the emulator from within Android Studio 1.5 has been removed.
(Weirdly, I don't seem to be able access the acceleration when starting the emulator from the command line once Android Studio 1.5 has been installed - but maybe I'm wrong.)

Resources