Thursday, July 4, 2013

[Guide] Getting into Android Development–speeding up the emulator on Intel platform using Intel HAXM


We guys in Japan are finally going to do some development for Android platform. First thing’s first. We need to setup the development environment.

I referred to the official development tutorial provided by Google. This means, I will be using Eclipse as the IDE. I downloaded and installed the Android SDK integrated version from Google. Here’s where you can download it from. LINK.

Since I don’t know anything about developing from Android platform, I started from the Building Your First App section. I did the coding for the Hello World app. Then it was time to run it. For that, I first had to create a Virtual Device because I don’t have an Android device with me.

The Crappy Emulator

There are a lot of restrictions. I first selected the Nexus4 device which comes with 2GB RAM, but the emulator doesn’t work if you specify more than 768MB RAM.


So I set it to 768MB RAM, and started the emulator. It took a whole 60 seconds to just load the OS. Fine. But the UI was even worse. It was so slow respond.


Would “Use Host GPU” option fix it?

I read somewhere that if you check “Use Host GPU” option, the UI becomes snappier. So I went into the Android Virtual Device I created before and did that. But that didn’t do any good.

Enabling Intel x86 Emulator Accelerator

So I searched the internet and found out that if you use Intel x86 Emulator Accelerator, you can make it snappier. This is how you enable it.

Launching Android SDK Manager

First you have to open Android SDK Manager. There is an icon for it at the root of the Android SDK you downloaded. But for some reason it would not launch for me. But there is a fix.

  • Close the Eclipse IDE if you have it open.
  • Open \sdk\tools\android.bat in a text editor. (Notepad for example)
  • Search for “set java_exe=”
  • There, enter the path where java.exe is installed. If you installed JRE to the default location, it would be at C:\Program Files\Java\jre7\bin\java.exe. Put the path within quotation marks.
  • Now it should look like this.

set java_exe=”C:\Program Files\Java\jre7\bin\java.exe”

  • Now save the android.bat file, and double click it to open Android SDK Manager.


Installing Intel x86 packages

In Android SDK Manager, select the following two options and click on Install Packages. It should be straightforward after that.


Now launch Android Development Environment (or Eclipse) and check the properties of your Android Virtual Device (or add a new one).


You will see that you can now select Intel Atom as the CPU.


However, if you try to launch the emulator after selecting Intel Atom as the CPU, it will still work as crappy as before. You will notice that there is an error shown in the console.

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

Installing Intel Hardware Accelerated Execution Manager

Looks like there is still work to do. Now we have to install Intel Hardware Accelerated Execution Manager. (HAXM).

Go to \sdk\extras\intel\Hardware_Accelerated_Execution_Manager and run IntelHaxm.exe to install Install HAXM.


However, for this to succeed, you have to have a CPU that supports Intel VT-x. You can check if your CPU supports VT-x using Intel Processor Identification Utility. Remember even if your CPU supports it, it might be disabled in BIOS/UEFI. So check there as well, and enable it.

Enjoy the speed

Now you are ready for action.

Open the Android Development Environment and in there go and add a new Virtual Device. For some reason, updating the existing Virtual Device didn’t work for me. From there, select Intel Atom as the CPU and rest of the settings as you please. I checked “Use GPU Host” option as well.

After that I launched the emulator. Woah! The difference was night and day. The emulator fully starts within 10 seconds. The UI is fluid, just as running inside the real hardware.

Now it is time to develop. :)

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...