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

2

5 Answers 5

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.

7
  • my question already says this was attempted, I ultimately found that kvm was disabled on my azzo managed vps.
    – Jpsh
    Mar 11, 2018 at 6:49
  • 9
    Solved the problem for me. However, Re-Login is necessary after these commands. Apr 12, 2018 at 7:14
  • 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 ?
    – Fabich
    May 1, 2018 at 21:37
  • 2
    @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.
    – Afflicted
    May 16, 2018 at 13:57
  • it didn't change anything, android studio still shows error message with kvm
    – user25
    May 31, 2018 at 17:22
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

2
  • 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.
    – luckyrat
    Jun 25, 2019 at 11:25
  • Worked for me as well +1 from my side. Jun 27, 2019 at 10:01
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.

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!

1
  • 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.
    – Jpsh
    Dec 10, 2018 at 23:06
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .