Boost Android Emulator Performance

As a n00b trying to figure out Android development, I fell into the same experience of many who have wondered and complained about the slow performance of the Android Emulator. Fortunately, I was pointed to this article before a training. The article describes that we can actually download and install the Intel® Hardware Accelerated Execution Manager (HAXM) to boost the performance of the Android emulator on Windows machines.

Since I'm running on Windows Server 2012 R2, I downloaded the version which promises to be a hotfix for Windows 8.1 but when I try to install it, I got the following:



This computer does not support Intel Virtualization Technology (VT-x). HAXM cannot be installed. Please refer to the Intel HAXM documentation for more information.

I was puzzled by the error message since my machine has Hyper-V installed and I'm pretty sure that my VT-x was enabled in the BIOS. I proceeded to download the Intel® Processor Identification Utility just to be sure and I got the following:



What the ...

Anyway, after some research I found out that the hypervisor layer that Hyper-V installed was interfering with the tool. Now, I'm caught in-between. I am running on a Server workstation (is there such a term?) and I need Hyper-V for my VMs and Windows Phone 8 development. I don't want to un-install Hyper-V just because I wanna try out some Android development.

Fortunately, I discovered a trick which can let me boot my Windows without loading the hypervisor layer temporarily. To achieve this, some bcdedit acrobatics is required. Please take note that playing with bcdedit may lead you into disastrous results such as not being able to boot up your machine - so don't say I didn't warn ya. ;)

If you open up a command prompt (in Administrator mode please!) and type in bcdedit, you should get something like the following:


Notice the hypervisorlaunchtype is set to Auto. Now, let's create a backup entry of that for our no Hyper-V version (cos I don't want to screw up the original). Issue this command to clone an entry.

bcdedit /copy {current} /d "Windows Server 2012 - No Hyper-V"

You should get a message telling you that the current entry has been copied to a new entry with some identifier GUID. If you type bcdedit again, you should be able to see the new entry with the same hypervisor setting. Issue the following command to disable it.

bcdedit /set {the-identifier-GUID-of-the-entry-you-just-created} hypervisorlaunchtype off

If you have done it correctly, you should be able to get something like the following:


Now that the setting is off, you can reboot your machine (and pray) and when prompted, select to boot with the Windows Server 2012 - No Hyper-V entry. You should not feel any difference other than Hyper-V is being switched off. With this you can now install HAXM without any problems.

Note: When installing HAXM, you will be asked to allocate an amount of memory. I took the default 2GB.

Now stuff doesn't just stop here. After you have HAXM installed, launch the Android SDK Manager from your Android IDE i.e. eclipse or Xamarin. Make sure you checked on the Intel x86 Atom System Images for the Android API levels that you want and install it.


Also remember to scroll to the bottom and check the Intel x86 Emulator Accelerator (HAXM) to install it.

Once they are installed, launch the Android Virtual Device Manager and create a new Android Virtual Device (AVD). At the create screen, select Intel Atom x86 for the CPU/ABI and make sure you check Use Host GPU.


Note: If you decide to put anything higher than 768 for RAM here you will get a warning saying:

"On Windows, emulating RAM greater than 768M may fail depending on the system load. Try progressively smaller values of RAM if the emulator fails to launch."

You may ignore that and give it something larger. I gave mine 2048 but if you try to start the emulator now, you may encounter the following error:


To fix this, go to your user folder and locate the folder of the AVD that you are trying to start i.e.

C:\Users\Administrator\.android\avd\Note3.avd

Open up the config.ini file with a text editor and locate the hw.ramSize= entry. Change whatever value that it has to suffix with an 'mb'. i.e.

hw.ramSize=2048mb

Save it and whalla! Your Android Virtual Device can now be started and will run at awesome speed.

No comments:

Post a Comment

Popular Post