When I try to run my Android app on an emulator I get this error:
/dev/kvm permission denied.
I checked the permissions and ad
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.
Provide appropriate permissions with this command
sudo chmod 777 -R /dev/kvm
There's absolutely no need to install qemu-kvm
(and all its dependencies) if you only want to run the Android Studio Emulator.
The only thing you have to do is to give your user (i.e. the one you are logged in with) the right to access the /dev/kvm
-device.
This is done in three simple steps.
First:Create the kvm
-group
groupadd -r kvm
The option -r
creates a system group, i.e. with a GID <= 999 (see /etc/login.defs
=> SYS_GID_MAX
)
Change permissions on /dev/kvm
. This could be done as part of the qemu-kvm
-installation, because one of the dependencies is installing qemu-system-common
(on current Ubuntu systems, package name may vary), which in turn installs the file /lib/udev/rules.d/60-qemu-system-common.rules
containing the following:
KERNEL=="kvm", GROUP="kvm", MODE="0660"
So if you are just create a file /etc/udev/rules.d/60-qemu-permissions.rules
containing the above line, you are done with the first step.
Add your username to the group by executing
usermod -a -G kvm <your_username>
- the -a
is important for adding your user to the kvm-group. Without that you will overwrite the group-settings for your user to only belonging to "kvm"...
That's it.
For the new udev rule and group setting to take effect it's easiest to reboot and login again.
You can also execute
udevadm control --reload-rules && udevadm trigger
for reloading the rules but you still have to logout and login again with regard to the new group.
Type in terminal:
sudo apt install qemu-kvm -y
sudo chown $USER /dev/kvm
I tried sudo setfacl -m u:UserName:rwx /dev/kvm
. and it works .
In the android studio you need to change : tools> avd manager >(chose the pen to edit your device and change 'graphics' from automatic to software ) to avoid emulator drawable error
sudo chown $USER /dev/kvm
Simply running that one command worked for me here in September 2019 running:
Description: Ubuntu 18.04.3
LTS Release: 18.04
Codename: bionic