Using the HAXM Accelerator for Android

By | 2014-06-27

Developing Android applications on Mac OS X is easy, especially if you are using Google’s new Android Studio or JetBrain’s IntelliJ. Also when you install Google’s SDK, you’ll get plenty of tools for creating virtual devices to test on. I created a Nexus 7 virtual device, and although it ran slowly, it did run smoothly. I soon got used to the workflow that involved running and testing my application on a different device (real and virtual).

After a few cycles of code, deploy to device, and test, I realized I was spending too much time waiting for the virtual device to load. I had randomly opted to run my AVD using an ARM system image, and other developers claimed that running on the Intel Atom CPU image would provide better performance for the time-consuming workflow. I decided that I’d give the Intel CPU image a try.

Using the Intel x86 image and reaping the benefits of a faster emulator requires that you install 2 additional items available in the Android SDK:

  1. Intel x86 Atom System Image
  2. Intel x86 Emulator Accelerator

You install the x86 CPU image from within the Android SDK Manager. The SDK Manager lists the different API versions, and you can see options to install system images. Install the x86 image by clicking the x86 option and then clicking on the “Install package” button.

Intelx86CPUImage

From within the SDK Manager, you can also install the x86 accelerator. Look for the “Extras” section that includes the option to install the Intel x86 Emulator Accelerator (HAXM). The option looks like this:

Intelx86IntallOption

After installing these options, you then select the Intel Atom x86 cpu image from within the AVD manager:

Cpuchoice

Running the AVD using the new image may have provided some speed improvement, but I really didn’t notice much. I was a bit disappointed. Then I discovered that I was supposed to also install HAXM. Wait, but didn’t I do that earlier in step #2? I thought I had, but actually I had only downloaded the HAXM installer. I caught on to this when I noticed the AVD startup dialog:

emulator: Failed to open the HAX device!
HAX is not working and emulator runs in emulation mode

Why did this warning message show up? I had used the SKD manager to install the needed pieces. By digging around in my Android SDK and “Extras” folders, I found a HAXM installer. I finally realized that although I had downloaded the HAXM installer, I had not actually installed HAXM itself. This isn’t perfectly clear when you select and install the HAXM option.

Extrashaxm

So, after you download the HAXM installer, look for it in your SDK folder. Install it. Run your emulator of an x86 processor, and….wow! An amazing improvement, and very noticeable. I was pleasantly surprised.

If you’re developing for Android, you’ll appreciate this information. It’s amazing how much it improves emulator performance. You’ll definitely see a difference in speed. You’ll be glad you installed both the x86 image and the HAXM accelerator. 

But remember…if you really want to get the benefits of the accelerator, you have to actually install it after you download it.

 

Leave a Reply

Your email address will not be published. Required fields are marked *