Enabling hardware acceleration for Android SDK emulator on Linux
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).
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:
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
And in the menu go to Tools > AVD Manager. Create a device with the settings as shown in the screenshot.
Important choices here are:
|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.Overzicht blogs