How to boost your Android emulator
I came across an article, which claims to boost the Android emulator’s performance using Intel’s Hardware Accelerated Execution Manager (HAXM) driver. It got me excited and I decided to verify this claim. This blog entry is my story.
Basically, the special ‘enhancement’ provided by Intel is a special x86 Atom system image which utilizes the HAXM driver that enables better emulator performance. I’ll not repeat the technical details here, you can access the links below for more info.
Caveat: This trick only works on Intel hardware and with the Virtualization Technology for Directed I/O (VT-d) enabled (usually via BIOS).
Also, Intel x86 system images are currently (as of this blog posting) available for Android versions 2.3.3 (Gingerbread), 4.0.3 (ICD), and 4.1 (Jelly Bean) only.
To avoid headaches, set the environment variable ANDROIDSDKHOME to point to your Android SDK root folder before proceeding.
Launch the SDK Manager and ensure the following is installed:
Next, you’ll need to install the HAXM driver manually. Go to the Android SDK root folder and navigate to extras\intel\HardwareAcceleratedExecution_Manager. Execute file IntelHaxm.exe to install.
Launch the AVD Manager and create 2 AVDs with the same options but different Target:
In IntelliJ, create a new project of type ‘Android Module’, as shown:
Under ‘Android SDK’, select the appropriate Android platform. You’ll need to point to your Android SDK root folder in order to choose the appropriate build target. As shown below, ‘Android 2.3.3′ is chosen:
Ensure that the ‘Target Device’ option is set to Emulator, then click ‘Finish’ to complete the project creation.
Ok, we’ll test using the default Android 2.3.3 AVD first.
At the IntelliJ menubar, select ‘Run’ > ‘Edit Configurations…’. Go to the ‘Target Device’ section. At the ‘Prefer Android Virtual Device’ option, select ‘DefaultAVD233′. Then Run the Android application. After a while, you should see the emulator window with the ‘Hello World’ message.
To run with the Intel AVD, choose the ‘IntelAVD233′ instead.
What’s most exciting is the speed of the emulator launch (timed from clicking ‘Run’ in IntelliJ up to the ‘Hello World’ message is shown in the emulator). The rough timings recorded using my notebook (Intel i3 380M, 3GB RAM):
Wow, that’s fast (~50% faster), without tuning other parameters to speed things up even further.