32

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

Jpsh
  • 421
  • 1
  • 4
  • 7

5 Answers5

43

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.

ch13mob
  • 541
30

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

Hossam.Y
  • 401
21

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.

earthmeLon
  • 11,658
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!

jakerz
  • 141
0

Update VT setting from Bios

  1. Power on the system and press[delete] key to enter BIOS [EZ Mode]
  2. Press [F7] key to enter BIOS [Advance Mode] as below picture: (If press [delete] key to enter [Advanced Mode] directly and then no need to press [F7] key any more)
  3. Select [Advanced] page and click [CPU Configuration] item
  4. Select [Intel(VMX) Virtualization Technology] item and set to [Enabled]
  5. Press [F10] key and click [OK] ,the system will auto reboot

https://www.asus.com/in/support/FAQ/1045141/#A