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

14.04android-studiokvmxrdp

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

Best Answer

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.

Related Question