About Mohamed Taman

Android: Boost up the Android emulator speed up to 400% on Intel based architecture

In my previous post How to inject Android compiled .apk package into its Device Emulator from the command line. I have demonstrated how to add your compiled .apk file to android emulator, from command line with adb command, included in ADT platform tools.

One of my friends commented: "Are u really using the emulator…..it is very slow. Even on the fastest machines. I always use a real device."

From this comment, I have made some R&D about this problem, and especially this tools are developed by Google ;), and indeed they know about this symptom.

Also testing on real devices are very costly and time consuming process, as we have a variety of devices varies from multiple screen sizes, which are one of Android developer’s worst nightmares. There are a huge number of different screen configurations of Android devices.

The great thing about using an emulator for development is that it gives you an opportunity to develop applications without having a real Android device. The default Android emulator comes together with the Android SDK and can be found in the "tools" folder.

So far so good, we have our coffee, but can we drink it? The answer comes about 5 minutes after we hit the "Launch" button. Go grab a coffee. Have breakfast. Come back. Wait another 5 minutes. Maybe even more.

In meantime, the default Android emulator is notoriously slow. So, what should we do? That is easy – start using a properly fast Android emulator.

Emulation vs. Simulation

If you are using Apple iPhone simulators, you will find that the iPhone simulator does not have the same issue as the Android Emulator.

One of the reasons for this is that it does not run a “real emulator”, because the CPU instruction used by the iPhone simulator is the same as the one used by the host (x86).

On the contrary, Android Emulator emulates a real ARM processor on top of an x86 processor. This is a lot of overhead.

At least for quick test and demonstration purposes, I do not need to emulate an ARM processor; I just need to be able to run Android and my application. The main objective before releasing an application is to find bugs and design imperfections.

Okay, it is slow. Then what can we do about it?

Let us go through steps to solve the slowness problem of Android emulator;

First, let us delegate the rendering process to host GPU instead of overhead our CPU by this process, it will make it happy. Do it by checking "Use Host GPU" checkbox in AVD’s edit window.

The screen should now look better and be more responsive. That is because the CPU is happy to not dealing with the tedious work of doing rendering anymore. However, that is still not fast enough.

Second we need to download Intel Atom (x86) system image for each Android version you need to use for testing.

The SDK only copies the Intel HAXM executable on your machine, and it is up to you to install the executable.

To install the Intel HAXM executable, search your hard drive for IntelHaxm.exe (or IntelHAXM.dmg on Mac OS X). If you left everything to default, it should be located at %Android_HOME%\sdk\extras\Intel\Hardware_Accelerated_Execution_Manager\IntelHaxm.exe.

Intel HAXM only works in combination with one of the Intel® Atom™ processor x86 system images.

In order to be able to install the Intel HAXM, you need to have Intel VT-x enabled in your BIOS, otherwise you will get an error like this during install.

VIP Note: You could say that this level of speed should be sufficient. That may be true, but an issue with the Intel x86 images is that you do not get Google Apps, they only come with ARM images. This is important if you are testing an app that uses GMaps, or Google Play Services.

4. Java Annotations Tutorial3>

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design

and many more ....

12 comments

Though the logic behind the change in emulation mode downright straightforward and I’d like to believe that I would have made such a change on my own after about a dozen times fighting with the ARM emulator, the fact is that many people are trained to quickly work /around/ their problems rather than potentially spending more time solving them. Because of that (and because I believe the Intel images were only recently introduced), I’m sure there are a ton of people that have simply turned to device-only testing when possible, before geting the chance to recognize this faster and more flexible option.

Thanks for spreading the word. I’m eager to try it out myself and see how well it works.

thanks for your post i have some problem with this , first i download intel atom x86 for androdi 4.4.2 and then install intelhaxm . but when i want to create a new virtual android i dont see intel atom x86 under cpu/bus can you help me about this problem thanks alot

Newsletter

Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

Email address:

Recent Jobs

No job listings found.

Join Us

With 1,240,600 monthly unique visitors and over 500 authors we are placed among the top Java related sites around. Constantly being on the lookout for partners; we encourage you to join us. So If you have a blog with unique and interesting content then you should check out our JCG partners program. You can also be a guest writer for Java Code Geeks and hone your writing skills!

Disclaimer

All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners. Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries. Examples Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.