Using Hardware Acceleration With The Android Emulator On Debian

Table of Contents

More fun lessons learned with Android Studio! This morning I learned how to get rid of libgl errors when running a VM on Debian Linux, and now I can focus on the next steps.

I created the my "Hello World" application from the Head First Android Development book but the performance was dreadfully slow when I chose the default settings. Here's how I fixed that on a system running Debian Stretch (9.x).


The official prereqs are on this page, but I have to admit that it's a little confusing and redundant.

The important things seems to be the following:

  • A 64-bit processor
  • A 64-bit OS
  • A VT-x-enabled processor

This tutorial does a really great job showing you how to check for VT-x in your processor. I just ran the following command:

grep --color vmx /proc/cpuinfo


Now that we can assume that you can even use hardware acceleration let's install KVM. The Debian Wiki has great instructions on how to do this.

Here's what I did on my system:

sudo apt-get install qemu-kvm libvirt-clients libvirt-daemon-system
sudo adduser tom libvirt
sudo adduser tom libvirt-qemu

Naturally, you'll want to replace "tom" with your username in most cases :-)

Now that KVM is installed let's test it with the following command:

$HOME/Android/Sdk/tools/emulator -accel-check

…and here's what I got:

KVM (version 12) is installed and usable.

Hooray! It looks like things are working.

Choosing The Right VM

Note: The instructions below are for Android Studio 3.0.1. Most of the instructions that I've found are for older versions that look quite a bit different.

At this point I thought I had everything figured out. Compatible CPU? Check. Installed and configured KVM? Check! But the problem was that it was still taking at least 30 seconds for my emulator to get to the home screen. Was acceleration even working?

The key is that when you create your VM you need to do the following on the Verify Configuration screen in the wizard (which should be the last one you see):

  1. Click on the Show Advanced Settings button.
  2. Scroll down to the Emulated Performance section.
  3. In the dropdown next to the Graphics label, choose Hardware.
  4. Click on the Finish button.

Please note that you may not be able to access the Graphics dropdown. If this is the case, either the VM doesn't support acceleration or there is still something missing from your system.

Personally, I've had better luck with 64-bit VM's then 32-bit VM's. Try both architectures if you have any issues.

Now when you start your VM it should run significantly faster.

Additional Resources

Last Updated .