What you can do when your Android Studio could not start AVD on Ubuntu 18.04

After experiencing repeated sudden system crashes, I decided to update my Linux environment. Since then, my Android Studio stopped working properly. Several problems were found with the AVD, JVM and Gradle project sync and so forth. And I needed to spend my weekend fixing one problem after another.

I had kvm installed, added myself to its users group and rebooted the system.

$ kvm --version
QEMU emulator version 2.11.1(Debian 1:2.11+dfsg-1ubuntu7.2)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers

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

$ ls -l /dev/kvm 
crw-rw---- 1 root kvm 10, 232 May 28 18:20 /dev/kvm

$ grep kvm /etc/group
kvm:x:128:femoghalvfems

Still it didn’t make any difference. The IDE kept showing the message “Error while waiting for device: Could not start AVD” and would never start the emulator.




This gave no clue what was going on. There had to be permission problems, I suspected. I changed the permission of the directory.

$sudo chmod 777 /dev/kvm

Of course, I knew it is usually not a good idea. Granting the full control permission to everyone would pose a threat to the entire system and even possibly cause another problem. But it worked, anyway. As I changed the directory permission, I became able to build apps using Android studio.

Unfortunately, the case was not yet closed. In the following hours, I got another system crash and had to reinstall the whole system from a bootable flash drive. My workstation contained NVIDIA and CUDA property drivers that conflicted with some other modlues from time to time. They froze all the processes and threads. I could not even raise skinny elephants.

So I reinstalled Ubuntu 18.04 LTS on my workstation and tried building apps with the latest Android Studio.

This time, I could open the AVD by simply adding myself to kvm user group. And it worked well! I didn’t do anything other than newly install a series of the required virtualization tools and add a new user. And it worked!

$ sudo adduser femoghalvfems kvm
Adding user `femoghalvfems' to group `kvm' ...
Adding user femoghalvfems to group kvm
Done.

Now I really don’t know what prevented the IDE from running the virtual machine.

Leave a Reply

Your email address will not be published. Required fields are marked *