Follow Us on Twitter

Enabling hardware acceleration for Android SDK emulator on Linux

by Patrick Sinke on March 7, 2015 · 2 comments

When using the Android SDK for testing mobile applications (for instance, created with MAF, Mobile Application Framework), you can utilize the GPU for hardware acceleration on the Windows platform. This will greatly improve the performance of the emulator. To be able to use the acceleration, you’ll need to install a separate package called Intel x86 Emulator Accelerator (HAXM installer).

Android SDK Manager

Android SDK Manager

If you’re on the Linux platform, you notice that the Status is  “Not compatible with Linux”. That’s not a problem because there is an easy workaround.

Here comes KVM to the rescue, being a full virtualization solution for Linux on x86 hardware.

Check if your CPU supports hardware virtualization,  by typing:

egrep –c ‘(vmx|svm)’ /proc/cpuinfo

If the result is 0, your CPU does not support hardware virtualization, which is necessary to run the KVM. If you get 1 or more, that means you’re fine.

Next, install KVM. First make sure if your processor supports KVM by typing:

kvm-ok

You will see this if that’s the case:

“INFO: Your CPU supports KVM extensions
INFO: /dev/kvm exists
KVM acceleration can be used”

If this is the result, you need to turn on Intel VT in BIOS:

“INFO: KVM is disabled by your BIOS
HINT: Enter your BIOS setup and enable Virtualization Technology (VT),
and then hard poweroff/poweron your system
KVM acceleration can NOT be used”

The next step is to install the KVM and a few other packages needed. To do so, type

sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

Add your user to some groups, replacing <user> by your own username:

sudo adduser <user> libvirtd
sudo adduser <user> kvm

Check if everything is ok:

psinke@psinke-WHLT-M4600:~$ sudo virsh -c qemu:///system list
 Id    Naam                           Toestand
----------------------------------------------------

No virtual machines are created (yet), but we don’t need them anyway.

Start the Android AVD Manager with the command
<android sdkhome>/sdk/tools/android

And in the menu go to Tools > AVD Manager. Create a device with the settings as shown in the screenshot.

android sdk avd managerAVD settings

Important choices here are:

Description Setting
Target Google APIs (or at least a target of type x86 System Image)
CPU/ABI Intel Atom (x86)
Use Host GPU Checked when available
Internal Storage Enough to store your app

When accepting the settings and pressing the “Start…” button, the hardware acceleration should be enabled automatically, providing a fast startup and smooth user experience in the emulator.

 

Note: if an error is thrown while starting the emulator (ioctl(KVM_CREATE_VM) failed: 16 Device or resource busy) you are probably running virtual machines in for instance Virtualbox. In that case, close the VMs and try again.

Enabling hardware acceleration for Android SDK emulator on Linux, 5.0 out of 5 based on 1 rating
Ratings:
VN:D [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)

{ 2 comments… read them below or add one }

Karthi July 4, 2015 at 9:45 am

I am a newbie with Ubuntu. When I typed:

egrep –c ‘(vmx|svm)’ /proc/cpuinfo

I get 0. So does this mean, I won’t be able to install KVM?

Reply

Patrick Sinke July 9, 2015 at 10:18 am

Hi Karthi, that might be the case. Most processors nowadays support virtualization, but for instance some older types of Core 2 Duo or low-end revisions of AMD processors do not.
Installation of KVM might be possible but a waste of time.

Reply

Leave a Comment

 

Previous post:

Next post:

About Whitehorses
Company profile
Services
Technology

Whitehorses website

Home page
Whitebooks
Jobs

Follow us
Blog post RSS
Comment RSS
Twitter