Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio: /dev/kvm device permission denied

When I try to run my Android app on an emulator I get this error:

/dev/kvm permission denied.

I checked the permissions and added the user I am currently logged in with to the kvm group. What is wrong?

like image 756
florian.R Avatar asked May 18 '16 13:05

florian.R


4 Answers

As mentioned in the comments, starting with Ubuntu 18.04 and Linux Mint Tara you need to first sudo apt install qemu-kvm.

To check the ownership of /dev/kvm use

ls -al /dev/kvm

The user was root, the group kvm. To check which users are in the kvm group, use

grep kvm /etc/group

This returned

kvm:x:some_number:

on my system: as there is nothing rightwards of the final :, there are no users in the kvm group.

To add your user to the kvm group, you could use

sudo adduser $USER kvm

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

As mentioned by @marcolz, the command newgrp kvm should change the group membership live for you. If that did not work, @Knossos mentioned that you might want to log out and back in (or restart), for the permissions to take effect. Or do as @nmirceac mentioned and re-login in the same shell via su - $USER.

like image 151
serv-inc Avatar answered Oct 13 '22 03:10

serv-inc


This is how I got it to work in Ubuntu 18.04

sudo apt install qemu-kvm

Add your user to kvm group using:

sudo adduser <Replace with username> kvm

If still showing permission denied:

sudo chown <Replace with username> /dev/kvm

Try it.

like image 33
Jerin A Mathews Avatar answered Oct 13 '22 04:10

Jerin A Mathews


Try this, it worked for me:

  1. sudo apt install qemu-kvm

  2. sudo chown -R <username>:<username> /dev/kvm

like image 51
Milan Avatar answered Oct 13 '22 02:10

Milan


This is because /dev/kvm is not accessible. To make is accessible from android studio run the below command

sudo chmod 777 -R /dev/kvm

It will ask for your password. After that restart Android Studio.

KVM is required to rum emulator. If you have not install it yet then install it

sudo apt install qemu-kvm
like image 37
Shalauddin Ahamad Shuza Avatar answered Oct 13 '22 03:10

Shalauddin Ahamad Shuza