30 déc. 2013

Speed boost your Android emulator

By default, the Android Emulator is software based. Firing it up takes around ~1min and it consumes a lot of CPU power and battery life, which is a pain when you are using a laptop.

Along with your installation of your Android SDK Manager, there is an extra option which allows you to install HAXM, the Hardware Accelerated Execution Manager from Intel. You find it just here :


However, once downloaded, this tool is not installed automatically. You have to execute it. Open a terminal and hit the following command :

open /usr/local/opt/android-sdk/extras/intel/Hardware_Accelerated_Execution_Manager/IntelHAXM.dmg

But wait, if you are on a OSX Mavericks or on Windows 8, don't start your Android emulator too quickly. The Android SDK provides an old release that would make your Mac or PC to hang (yerk). Fortunately, Intel provides a fix available in the Developer Zone.

OK, now, we are ready to speed up the Android Emulator.

Go back to your Android SDK Manager and in Tools > Manage AVDs , create a fresh Android Virtual Devices. In the creation pane, check the option Use Host GPU.

The speed boost is amazing: starting the Android Emulator takes now around ~30s. But it's not the only interesting side effect. Now, all your emulated apps go faster and it takes less, I mean really less, power on your host.

Just a couple of caveats though. Using the Android Emulator doesn't prevent you from testing your apps on real devices. As a matter of fact, the Intel Android Emulator uses your Intel processor (better being said than being sorry...). Therefore, your native code and by native I mean the real native code (the one being written in C or C++, not the Java code, which is called native but is more a Just in time interpretation of Java bytecode) may have quirks on MIPS processors that you just can't see on Intel's ones.