22

I am on Ubuntu 18.04 LTS and I am trying to set up Android Studio for the first time. When I run my simple "Hello World" app, it gives me a pop-up that says

KVM is required to run this AVD.
Unknown Error

Please file a bug against Android Studio

popup

But when I run simply kvm-ok it outputs:

INFO: /dev/kvm exists
KVM acceleration can be used
Zanna
  • 69,223
  • 56
  • 216
  • 327
Nomi Shaw
  • 425
  • 1
  • 3
  • 15
  • Did you check this Ask Ubuntu [thread](https://askubuntu.com/q/564910/550550)? – Shashanth Jul 04 '18 at 04:01
  • 1
    Yes i have, but the thing is that my CPU does support virtualization and is enabled from BIOS! – Nomi Shaw Jul 10 '18 at 08:31
  • You might try to just run 'kvm' as that will run a KVM with (x86) Bios with -enable-kvm being set. It will eventually stop as it has nothing to boot, but you will see if kvm can be used. – Christian Ehrhardt Jul 16 '18 at 05:56

5 Answers5

35

Starting with Ubuntu 18.04 and Linux Mint Tara you need to install qemu-kvm

sudo apt install qemu-kvm

Check the ownership of /dev/kvm

ls -al /dev/kvm

Check which users are in the kvm group

grep kvm /etc/group

Output from the above command

kvm:x:some_number:

If there is nothing rightwards of the final :, there are no users in the kvm group.

To add the current user to the kvm group

sudo adduser $USER kvm

which adds the user to the group, and check once again with grep kvm /etc/group.

A restart may be required for the permissions to take effect.

Official answer on StackOverflow

Kulfy
  • 17,416
  • 26
  • 64
  • 103
G. Spyridakis
  • 466
  • 6
  • 9
  • after adduser run this too...`sudo chown $USER /dev/kvm` – vamsi Apr 22 '20 at 06:24
  • Thanks @rogoro. Running `chown` solved problem without restart. – csonuryilmaz May 06 '20 at 19:16
  • Installing `qemu-kvm` is really not necessary for Android Studio, one can simply create the `kvm` (system) group and install a udev permission override to enable user access. See https://stackoverflow.com/a/61984745/624066 – MestreLion Sep 23 '20 at 14:58
  • @vamsi That does not really make sense. Do one or the other. If you add $USER to the `kvm` group that should be enough. Of course you have to logout/login. You have group rights then. Running that `chown` command makes $USER the owner of that device. That is not recommended as this is a strong change in system defaults. – Gerd Jan 26 '21 at 19:46
1

Change sdk emulator folder permission. This is worked for me.

chmod 777 -R {sdk folder}/emulator

https://stackoverflow.com/questions/44635879/kvm-is-required-to-run-this-avd-unknown-error-please-file-a-bug-against-androi

Toir
  • 19
  • 5
0

To run KVM, you need a processor that supports hardware virtualization.

To see if your processor supports hardware virtualization, you can review the output from this command:

egrep -c '(vmx|svm)' /proc/cpuinfo
  • If 0 it means that your CPU doesn't support hardware virtualization.

  • If 1 or more it does - but you still need to make sure that virtualization is enabled in the BIOS.

Installation of KVM

Cosmic (18.10) or later

sudo apt-get install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils

You need to ensure that your username is added to the group libvirtd, and kvm:

sudo adduser `id -un` libvirt
sudo adduser `id -un` kvm

Verify Installation

Run kvm-ok on the command line.

$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

Logout or restart for changes to take effect.

Sources:

https://developer.android.com/studio/run/emulator-acceleration#accel-check https://help.ubuntu.com/community/KVM/Installation

Gayan Weerakutti
  • 3,670
  • 26
  • 37
-1

I usually run

sudo chown username -R /dev/kvm

but this is only good for a while. Looking for a better solution.

There is also another command:

sudo adduser username kvm
ADNow
  • 99
  • 1
-1

Login as a root user sudo su goto the studio installation dir withcd ${path_of _installation_dir}/android-studio/bin and relaunch the sdk with ./studio.sh. Then try relaunching your avd

Rohit
  • 99
  • *Never* log in as the root user! There's nothing you could do as root, that you can't do with `sudo`. And if you only need the permissions of a specific group, `sg` if you belong to it, `sudo -g` if you don't — `sg kvm /bin/studio.sh` in this case, given the `kvm` group has read+write permission on `/dev/kvm`. – antichris Sep 06 '19 at 09:03