[Linux] How to speed up Android Emulator

  • 0
If you are using the android AVD emulator under linux, you may have noticed that its performance is very poor. However, to speed up the android emulator you can use Intels Hardware-assisted Virtualization (hypervisor). This How-To describes the necessary steps to enable Hardware-assisted virtualization on (X)ubuntu 13.10.

First you need to install KVM:
Check if your processor actually supports hardware virtualization:
 $ egrep -c '(vmx|svm)' /proc/cpuinfo  
A return value "0" means that your processor does NOT support hardware virtualization.
Now install cpu-checker:
 $ sudo apt-get install cpu-checker  
and check if your cpu supports KVM:
 $kvm-ok  
Now you need to enable Virtualization in the BIOS setup of your machine.
Now you have all the requirements fulfilled to install KVM:
 $ sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils  
After the installation you need to add your user to the "kvm" and "libvirtd" group:
 $ sudo adduser your_user_name kvm  
 $ sudo adduser your_user_name libvirtd  
Now it's time to reboot your machine, or simple logout and login again.
Start Eclipse and create a new Virtual device. Under CPU/ABI you should now be able to select "Intel Atom (x84)". If not you may want to install the "Intel x86 Atom System Image" for your desired Android API with the Android SDK Manager in eclipse.

To start the emulator use the command:
 $ <SDK directory>/tools/emulator-x86 -avd Your_AVD_Name -qemu -m 2047 -enable-kvm  
I recommend that you create a little bash script which uses the command above to start your AVD.


Note: if you want to start the AVD from eclipse do the following:
1) In Eclipse, click your Android project folder and then select Run > Run Configurations...
2) Select your Android project run configuration or create a new configuration.
3) Click the Target tab.
4) Select your AVD device.
5) In the Additional Emulator Command Line Options field, enter:
 -qemu -m 2047 -enable-kvm  

-- Sources: Ubuntu Documentation Intel Blog Post

No comments:

Post a Comment