Monday 4 June 2012

How to set Android 4.0 x86 emulator with GPU emulation on Windows machine

Couple days ago Google (in collaboration with Intel) released x86 version of Ice Cream Sandwich emulator. I've been using x86 version of Android 2.3 emulator since firs release. It's considerably faster than ARM version (roughly 2-3x faster), so I couldn't wait for the ICS support.

You can combine it with GPU acceleration, so UI is snappy (faster than 2.3 x86 with the same resolution), and all cool ICS effects (like smooth transitions, gradients etc.) are available. I personally prefer to develop on VM rather than physical device. I'm using dual monitor setup, so It's more convenient to just have emulator running on second screen, than to distract yourself by switching from keyboard to tiny touchscreen device.

Here are my step-by-step guide how to install and configure it with Eclipse with ADT plugin on Windows machine:

1. First, before you start:

- I recommend installing newest version of Android SDK (19.0.0 when I'm writing this).
- Update your graphics card drivers (I tested it on nVidia GeForce 8800GT as well as on 8400GS which is roughly 10x slower than 8800GT but there was no performance differences on both cards running Android emulator). I recommend using drivers directly from your graphics card vendor. I had some problems with drivers downloaded by Windows update service.
- You need to have CPU supporting Intel VT-x technology (similar AMD technology is only supported on Linux - another reason not to buy AMD CPUs ;)). If you're not sure your CPU has it, you can always download CPU-Z (there is "no installation" version available, just download it, unzip and run). It will tell you your CPU specs. Red arrow on screenshot below shows where you can find info about presence of this technology.


 2. Run Android SDK Manager and download x86 system image.


3. Start Android Virtual Device Manager and add new device using specs from screenshot below. Add new filed in "Hardware" table called "GPU emulation" but leave it set to "no" value for now (I will explain why in a moment). You can choose whatever you like for "Name", SD Card "Size" values and device screen resolution. DO NOT ENABLE SNAPSHOT! Save machine but don't run in yet.


4. Download Intel Hardware Accelerated Execution Manager and install it. If you're tight on system memory you can decrease value of RAM used by VM. The VM will use all memory set in HAXM so you can easily change value to 512MB (more than plenty for ICS in 800x480 resolution and you can always change it by running HAXM executable after installation).


5. Now comes the tricky part. I'm not sure if that was my setup's fault, but VM refused to boot properly when I set GPU emulation on first start. So I recommend you start it up first without it. Run your VM, it can take a while to boot for the first time (2-3 minutes on my machine, you should see animated "Android" logo after about 30 seconds). You should get report that HAXM is working (more details are available in LogCat logs).



6. When it boots turn it off, edit preferences, set "GPU emulation" value to "yes", save it and try run it again. You can tell GPU emulation is working by opening system menu. Characteristic gradinet should be visible (right part of the screenshot below). If it won't start at first, try and run it again. After first successful boot there should be no further problems running VM.


As I said before, I strongly recommend giving it a try. This 2-3x performance difference is a huge deal and saves you a lot of time if you do a lot of Android development. Application testing process becomes much faster and enjoyable. The only drawback is the fact that in current version of x86 emulator (as well as when you use GPU emulation on ARM version) you can't use snapshots. After first boot emulator starts in about 2 minutes on my machine (Windows 8 RP, Intel Dual Core e5300@2,6Ghz, 4Gigs of RAM and (unfortunately ;)) 7200RPM modern HDD). But you only have to start it once during development day and leave it running so it's not that big of a deal.

3 comments:

  1. Anonymous06 June, 2012

    Is there a way to emulate Tablet using this tutorial?

    ReplyDelete
  2. Yes there is. Just set your emulated device's resolution to WSVGA or WXGA (you need to change HAXM's memory usage to at least 1024 to emulate WXGA) and VM should start in tablet mode, with horizontal display mode, on-screen buttons and tablet layout.

    ReplyDelete
  3. i have a e2160 which doesn not have vt-x. The emulation is painfully slow.

    I was thinking of buying a cheap e3400 for the vt-x but even a 3ximprovement would not be enough imho. If you say that the UI is responsive, then i might go for it. Does the speed bother you?

    With my maching the animations were not smooth at all, several seconds between frames.

    ReplyDelete