Building the Android emulator for Windows

Today I’ve been investigating an argument parsing bug in Android’s emulator on Windows (a bug that may affect all platforms). The version I’m seeing the bug was in the Android SDK r12 version of the emulator [Yep, r13’s out – see note below.]

As part of this, I needed to rebuild the emulator. It was not as straightforward as I’d hoped so I decided to write up a little howto here in case others decide to try rebuilding it on Windows. It’s really not hard at all once you install a few prerequisites! [Note: You’ll also find info here about building this via Linux.]

[Edit: As of this post the HEAD is 6e2f62…599648 for platform_external_qemu. While this post-r12 work WILL build in Windows with these procedures, I just found out that the older r12 code (tagged as android-sdk-tools_r12) will NOT build in Windows! You’d need to do r12-based builds in Linux with MinGW installed. It’s interesting to see just how much was fixed since SDK r12… including, evidently, the very issue I discovered today! Hopefully SDK r13 gets released soon. Oh look, it’s out! Interestingly, unlike r12 there is no corresponding r13 tag for this one… which is part of why I didn’t notice it in the Git log (I saw the tools_r13 branch though there are lots of changes after that).]

Note: If you choose other install dirs, adjust the values below accordingly!

Install Python 2.6 or 2.7:

Install MinGW (it includes msys now):

Install Git: I use msysgit because I also use (and happily recommend!) TortoiseGit

Open a command prompt and ensure your path is set correctly (omit duplicates as necessary, but ensure such entries weren’t eclipsed by other things you’ve installed, like Cygwin):

set PATH=C:\MinGW\msys\1.0\bin;C:\MinGW\bin;C:\Python27;C:\Git\bin;%PATH%

Clone the repository! (Because of the outage we’re using the github mirror):

mkdir H:\temp_repo
cd /D H:\temp_repo
git clone

Start bash in the folder with the emulator sources (from this point on commands run at the bash prompt):

cd /D H:\temp_repo\platform_external_qemu

Setting PS1 makes the prompt more verbose than the default “bash-3.1$” prompt:

PS1='\[\e]0;\w\a\]\n\[\e[36m\]\u@\h \[\e[32m\]\w\[\e[0m\]\n\$ '

There’s a small problem if you want the version string in the emulator to be fully formed:

  • In Makefile.common, ANDROID_BUILD_ID get set only if BUILD_STANDALONE_EMULATOR == “” – never if BUILD_STANDALONE_EMULATOR == ‘true’ (which is what we’re building here). Here’s a fix for that, at least for the 13.x line of the emulator (line numbers may vary!):
    • Broken: line 66: ifeq ($(BUILD_STANDALONE_EMULATOR),)
    • Patched: line 66: ifneq ($(BUILD_STANDALONE_EMULATOR),false)
  • If in doubt, ignore this tweak! Understand your -version output will not be very informative. That can quickly get annoying if you are building multiple versions…

Set some variables and run the build:

# Customize this as desired
export ANDROID_BUILD_ID=custom

# Inserts your username and the timestamp in the build name
export MY_BUILD_TIMESTAMP=`date +%Y%m%d_%H%M%S`

# Executes the build
./ --static 2>&1 | \
   tee build_${USERNAME}-${MY_BUILD_TIMESTAMP}.log

Check the version string of the emulator you just built:

  • Run this:
    • objs/emulator.exe -version
  • See output like this:
    • Android emulator version 13.0 (build_id Marty-20110925_042430)

Using the newly-built emulator:

  • The objects of interest in objs are:
    • emulator.exe, emulator-arm.exe, emulator-x86.exe
  • You may need to copy them to android-sdk-windows/tools folder to use them (back up the originals first before replacing them!)

Notes on building via Linux:

As mentioned above, I managed to get all this to work on Windows just fine… technically, no source edits are necessary at this point to make it work. However, when I switched to the android-sdk-tools_r12 tag it failed with:

cc1: error: unrecognized command line option “-mno-cygwin”

Turns out this is a known issue… and in fact it was fixed in a later commit to the emulator code base! (I saw it as I was browsing the overall delta between r12 and the latest.) But, even with that fixed I couldn’t get r12 to build within Windows, so I went to Linux. I was already configured to build CyanogenMod, so everything was in place except MinGW. I installed mingw32, made that one fix to and ran:

./ –static –mingw

And it worked just fine!

(Note: the –mingw option is NOT used when building this within Windows… it’s a little confusing because of course we’re using MinGW in Windows, but that’s how it’s coded in their build system.)


  1. Hey there, great work.

    I’m interested to know – how is the performance of the windows emulator? Does it fly pretty fast? The ‘out of the box’ emulators are Linux and of course run very slow on windows.

    Also – does it seem to run all apps pretty well?


  2. I think it worked pretty well (though it was definitely slower for Honeycomb work), but having a modern machine helps.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.