Ubuntu 14 Android Studio 3 xrdp /dev/kvm permission denied

63,961

Solution 1

I had this mistake with Android Studio 3.0.1 on Ubuntu 18.04 when I run emulator. You can try this answer. To add the user username to the kvm group, you could use:

sudo apt install qemu-kvm
sudo adduser $USER kvm

In my case it worked, albeit with a re-login required after whole process.

Solution 2

it is too late answer , may be help another users .

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

Solution 3

This works for Ubuntu 18.04:

  1. Open a terminal and type the following

    • sudo setfacl -m u:$USER:rwx /dev/kvm
  2. Restart Android Studio.

Solution 4

Make sure virtualization is enabled in BIOS. Add your username to the group properties:

sudo chown :$USER /dev/kvm

let the user access/write to the device /dev/kvm:

sudo chmod g+rw /dev/kvm

that's it!

Share:
63,961

Related videos on Youtube

Jpsh
Author by

Jpsh

Updated on September 18, 2022

Comments

  • Jpsh
    Jpsh over 1 year

    I'm running an Ubuntu Server VPS with 4 dedicated cores and 4GB or ram

    lsb_release -a 
    

    says I'm running

    Description: Ubuntu 14.04.5 LTS 
    Codename: trusty
    

    I've installed Android Studio 3.0.1 I more or less followed this Tutorial just got the latest version. the install when smoothly.

    I then installed xrdp and xfce4, and I'm not having any issues with the remote connections

    I launch android studio with the following command from an elevated terminal window in rdp

    sudo ~/bin/android-studio/bin/studio.sh
    

    the command outputs

    Error parsing gtk-icon-sizes string: ''
    

    but android studio runs fine and allows my to make projects and code so I tried compiling the hello world app and running it in a ADV after creating an android virtual phone and trying to run I get the following error

    KVM is required to run this AVD.
    /dev/kvm device: permission denied
    Grant current user access to /dev/kvm
    

    I've run

    usermod -aG kvm *username*
    usermod -aG libvirtd *username"
    adduser *username* kvm
    adduser *username* libvirtd
    adduser *username* xrdp
    chmod +x /dev/kvm
    chown *username* /dev/kvm
    chmod -R 777  /dev/kvm
    

    I rebooted the VPS after each of the commands and I still get the KVM permission denied error

    When I run

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

    However if I just run

    kvm-ok 
    bash: kvm-ok: command not found
    

    I've been trying to figure this out for hours now and have only found stuff telling me to add the user to kvm and/or libvirtd groups any help would be greatly appreciated.

    Update:

    Looking into this some more

     cat /proc/cpuinfo | grep 'name'| uniq 
     model name : Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz
    

    so I ran

    sudo modprobe kvm-intel
    modprobe: ERROR: ../libkmod/libkmod.c:507kmod_lookup_alias_from_builtin_file()
    could not open builtin file '/lib/modules/3.13.0/modules.builtin.bin'
    

    this lead to me trying

    depmod -a
    depmod: WARNING: could not open /lib/modules/3.13.0/modules.order: No such file or directory
    depmod: WARNING: could not open /lib/modules/3.13.0/modules.builtin: No such file or directory
    

    here is the out put of ls -al /lib/modules/3.13.0/

    drwxr-xr-x 2 root root  4096 Dec 12 01:08 .
    drwxr-xr-x 5 root root 12288 Dec 11 18:11 ..
    -rw-r--r-- 1 root root    45 Dec 12 01:08 modules.alias
    -rw-r--r-- 1 root root    12 Dec 12 01:08 modules.alias.bin
    -rw-r--r-- 1 root root     0 Dec 12 01:08 modules.builtin.bin
    -rw-r--r-- 1 root root     0 Dec 12 01:08 modules.dep
    -rw-r--r-- 1 root root    12 Dec 12 01:08 modules.dep.bin
    -rw-r--r-- 1 root root    52 Dec 12 01:08 modules.devname
    -rw-r--r-- 1 root root   131 Dec 12 01:08 modules.softdep
    -rw-r--r-- 1 root root    49 Dec 12 01:08 modules.symbols
    -rw-r--r-- 1 root root    12 Dec 12 01:08 modules.symbols.bin
    

    so I was thinking there was an error with my linux image, but

    sudo apt-get install linux-generic
    Reading state information... Done
    linux-generic is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    

    not sure what to fix but I think I'm getting closer to figuring out the issue at least

    • Admin
      Admin over 5 years
      I ultimately found that kvm was disabled on my azzo managed vps. the VPS was destroyed nearly a year ago, so I can't try any answers.
    • Admin
      Admin almost 4 years
      See also my answer to a similar question on StackOverflow: Android Studio: /dev/kvm device permission denied
  • Jpsh
    Jpsh about 6 years
    my question already says this was attempted, I ultimately found that kvm was disabled on my azzo managed vps.
  • Akshar Patel
    Akshar Patel about 6 years
    Solved the problem for me. However, Re-Login is necessary after these commands.
  • Fabich
    Fabich almost 6 years
    I had the same problem after upgrading to 18.04 and your answer solved it ! Can someone explain what is qemu-kvm and why it is now required ?
  • Afflicted
    Afflicted almost 6 years
    @Fabich KVM = Kernel-Based Virtual Machine. It allows for different architecture emulation. I'm also trying to get android studio running on 18.04 sadly nothing has resolved this for me.
  • user25
    user25 almost 6 years
    it didn't change anything, android studio still shows error message with kvm
  • ch13mob
    ch13mob almost 6 years
    I'm not sure if this will help, try install: sudo apt install cpu-checker
  • Jpsh
    Jpsh over 5 years
    was VPS with no access to bios, tried first command (see question) and I did chmod -R 777 /dev/kvm so I feel like that would have worked, regardless VPS no longer exists and I can't test it.
  • luckyrat
    luckyrat almost 5 years
    Thanks. Step 1 worked for me. Not sure what step 2 is for but seems unrelated to the main problem and I didn't need to do it.
  • Pravinsingh Waghela
    Pravinsingh Waghela almost 5 years
    Worked for me as well +1 from my side.
  • JaydeepW
    JaydeepW over 4 years
    Combination of this answer and some commands from below answers helped me get this working in 2019!