This article explains how to setup the HAXM emulator accelerator to speed up the android emulator and thereby improving the MAF development experience on the Android emulator. An Android virtual device (AVD) emulates the entire device right down the last detail. By default the Android emulator models an ARM processor and it does this right down to the register level. Emulating an entire processor’s operations using only software is a demanding task and this is why the android emulator is slower than an actual device based on an ARM processor design. As an alternative, Intel provides an x86 based Android system Image as part of the android SDK. This system image can leverage the Intel HAXM virtualization engine when running on Intel processors to speed up the emulator. Intel HAXM is a hardware assisted hypervisor that makes application development on Android platform faster and more efficient. To use HAXM, your development workstation needs to be using an Intel processor that supports VT-x technology. You also need to create an Android virtual device based on the x86 Atom System Image provided by Intel (You can download this from within the Andoid SDK manager).
If you are using Linux, you will need to use the KVM to enable kernel based virtualization. Please refer to Intel documentation for installation on Linux with KVM
If your development computer is running either Microsoft Windows 8.n or later, or Mac OS X 10.9.n or later, you have to apply a hot-fix provided by Intel to fix issues with the Intel HAXM driver before using emulator with the Intel HAXM (HAXM release 1.0.8). If you do not apply the hot-fix, your computer will freeze and you will loose your work. Using these instructions, you should get the latest HAXM release (1.0.8, at the time of writing) which includes this hot-fix. However, it would be prudent to check on the latest news and updates on HAXM directly on Intel’s website here.
Checking the box next to HAXM and clicking “Install” in the SDK manager simply downloads the HAXM installer to your workstation. You need to run the installer executable that is downloaded.
The installer is downloaded to an “intel” subdirectory of the “extras” directory under the sdk location. Running the downloaded executable launches the installer and it checks your system for compatibility and ask you for the total amount of RAM that will be reserved by HAXM across all emulator instances you will run. You can change the amount of RAm reserved by HAXM by re-running the installer again at a later time. Note that occasionally, the virtualization technology offered by the processor is disabled by your BIOS. If the processor you use supports VT-x, but the installer detects that VT-x is not turned on, then you should enable virtualization features through your BIOS.
Setting up a HAXM based Emulator
Once the HAXM driver has been installed, you can create an Android Virtual device that will take advantage of this. Note that only x86 based system images can take advantage of the Intel HAXM (not the ARM based system images), and to create x86 based AVDs , you need to download the Intel x86 based System Image or the Google APIs x86 System Image.
Downloading an x86 System Image
These system images are specific to the version of Android release or API level. They also typically come in two flavors, a sytem image that contains the vanilla AOSP (Android Open Source Project) build or one that includes Google’s proprietary APIs and apps preinstalled. Typically you would want to use the more fully featured Google APIs System image (see tip window below). To download the system Image, open the SDK manager and drill down to the desired API level/Android version. Here you should see the option to download an x86 Atom based system image, next to the ARM based system image. Intel x86 Atom System images are not available for very old Android release, adn at the time of writing, they are are available for API level 10 (Android 2.3), and all versions including and above API level 15 (Android 4.0.3+)
If you are unsure whether to use the AOSP build or the Google APIs build, you should try to select the Google APIs build if one is available. This gives you access to a wider array of APIs and services, that are not part of the Android Open Source Project, like Google Maps, Google Cloud Messaging for push notifications and so on. What you are doing here is selecting a platform to test your application and therefore, you should choose a platform that supports the features you plan to build in your application. If your application uses Google’s services, you will need an android virtual device that includes the Google APIs to test these features in your application. A full discussion on the pros and cons of having a dependency on the Google APIs is out of scope for this article, but you can learn more about AOSP and the Google Services at the AOSP developer portal and Android developer portals respectively.
Creating an x86 based AVD
Once the system image is downloaded, you can create the AVD (Android Virtual Device) using the Android AVD manager. To create one, open the AVD Manager, and click on ‘Create’.
Note the two configuration options highlighted, that shows the CPU/ABI set to ‘Intel Atom x86’ and the option to use host GPU is enabled. The target drop down lets to switch between an AOSP system image and one that supports Google services.
Test your Setup
You can now start the AVD, and you should notice that the boot time and the general operations are magnitudes faster than the ARM based AVD. To ensure that HAXM is being used when you run the AVD, you can check for the message indicating that the emulator is running in fast virtual mode on the launch dialog. With HAXM enabled, the development of MAF based applications on the Android platform becomes quick, easy and efficient. Developers can get faster deployments, efficient and natural debugging and a more responsive and representative simulation of how the application would behave and perform on a real device without ever having one.
All site content is the property of Oracle Corp. Redistribution not allowed without written permission