Android Studio: /dev/kvm device permission denied

后端 未结 27 3121
鱼传尺愫
鱼传尺愫 2020-12-02 03:12

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

相关标签:
27条回答
  • 2020-12-02 03:48

    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.

    0 讨论(0)
  • 2020-12-02 03:48

    Provide appropriate permissions with this command

    sudo chmod 777 -R /dev/kvm
    
    0 讨论(0)
  • 2020-12-02 03:49

    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)

    Second:

    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.

    Third:

    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.

    0 讨论(0)
  • 2020-12-02 03:50

    Type in terminal:

    sudo apt install qemu-kvm -y
    sudo chown $USER /dev/kvm
    
    0 讨论(0)
  • 2020-12-02 03:51
    1. I tried sudo setfacl -m u:UserName:rwx /dev/kvm . and it works .

    2. 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

    0 讨论(0)
  • 2020-12-02 03:52
    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

    0 讨论(0)
提交回复
热议问题