Wednesday , 24 May 2017
Home » Personal » Communities » Compiling Android Source on Mac OS X 10.6 Snow Leopard

Compiling Android Source on Mac OS X 10.6 Snow Leopard

After various attempts, I’ve finally figured out how to compile the android source code on Mac OS X 10.6 Snow Leopard. It works on both 64-bit and 32-bit kernels. Here are the steps.

1. Install XCode, Macports, repo, etc.

I assume everyone knows how to do this. Follow the instructions from the Android source page. Just remember to create a new partition that is a case-sensitive partition if you’re using a non case-sensitive primary partition. I’ll start off after you’ve gotten the source from git.

2. Get the following patches.

Notice that I didn’t use “repo download” to get those patches. I realized that repo sometimes “undo” the patches when you download another patch. All bash commands start at the root of your Android source directory.

Patch 12074 – Change Ic4caeff0: Enable building on java 1.6 without conflicts.

This patch will allow you to use Java 1.6 that comes with Snow Leopard instead of Java 1.5.

[sourcecode language=”bash”] cd build
git pull git:// refs/changes/74/12074/3

Patch 11845 – Change I155a531a: Add x86-64 checking for Darwin

This patch will add x86-64 checking for Darwin.

[sourcecode language=”bash”] cd system/core
git pull git:// refs/changes/45/11845/3

Patch 11846 – Change Id241a12d: Force gcc-4.0 for qemu build on Mac OS X

This patch allows qemu to build.

[sourcecode language=”bash”] cd external/qemu
git pull git:// refs/changes/46/11846/3

Patch 12597 – Change I0a8c2440: Use intptr_t for args expecting pointers

This patch allows libacc to compile.

[sourcecode language=”bash”] cd system/core
git pull git:// refs/changes/97/12597/1

3. Build and watch it fly.

[sourcecode language=”bash”] make

I haven’t quite tested the image files and binaries but it seems to me like it works pretty well. Now to get my hands dirty and start messing around with the actual code.

Oh and remember, every time you do a repo sync, you might have to reapply some of the patches. I’m not too sure why. If there’s anyone who understands git well enough, please explain.

(UPDATE): New updated blog post for Android 2.1 – Compiling Android 2.1 Eclair Source on Mac OS X 10.6 Snow Leopard

About Justin Lee

Check Also

Editor of STOMP Ostracizes Google Android Platform when receiving SiTF Award

Mr. Chew V Ming (right), Editor of STOMP, ostracized the Google Android Platform not once …


  1. Hey Justin,

    Nice post – following your instructions everything builds fine (great) but the emulator crashes on startup… did you run into that at all?

    (Referring to the framework emulator not the SDK AVD one – haven’t tried a ‘make sdk’ yet)


  2. Nevermind the above, apparently the emulator crashes if you have a usb headphone/mic plugged in due to failure in the audio drivers!

  3. Ah. Thanks good to know. I haven’t tried it with a headphone or mic plugged in.

    Thanks Andrew! 🙂

  4. In order to get this to work, I had to install the MacOSX10.4.sdk into /Developer/SDKs. Since I had a fresh install of Snow Leopard I had only installed XCode 3.2.x which does not come with the 10.4 SDK. I downloaded XCode 3.1.4 from Apple’s developer website, navigated through the Packages directory and installed the “MacOSX10.4.Universal.pkg” file into /Developer.

    I also had problems compiling qemu (which is forced to use gcc-4.0 in the makefile). I don’t know if my installation of gcc-4.0 was broken to begin with, but it had trouble finding some default include files (stdarg.h in particular). I solved this problem by changing the following lines in
    # We are on Snow Leopard or above
    MY_CC := gcc-4.0
    with these lines:
    # We are on Snow Leopard or above
    MY_CC := gcc-4.0 -I/Developer/usr/lib/gcc/i686-apple-darwin10/4.0.1/include/

    All of the host code seems to compile OK, but I am still having issues compiling the ARM target code. I get ridiculous errors about lines of code in stddef.h – specifically:

    /usr/include/stddef.h:74: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ptrdiff_t’
    /usr/include/stddef.h:83: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘size_t’

    anyone else run into this issue?

  5. well – I solved my own problem: I don’t know how it ended up there, but my copy of “stddef.h” in /usr/local seems superfluous. I removed it (renamed it) and the compile completed just fine.

    Thanks for this quick HOWTO!

  6. Thanks Jeremy for your additional insights to get it to work. You’re welcome. 🙂

  7. Thanks Justin, was looking for something like this!
    Thanks to Jeremy as well, your tips were right on.

  8. I am having a different problem, I get few warnings like these

    ld: warning: in out/host/darwin-x86/obj/EXECUTABLES/emulator_intermediates/distrib/libpng-1.2.19/pngerror.o, file is not of required architecture
    ld: warning: in out/host/darwin-x86/obj/EXECUTABLES/emulator_intermediates/distrib/libpng-1.2.19/pngget.o, file is not of required architecture

    And then the following error is throw.

    Undefined symbols:
    “_main”, referenced from:
    start in crt1.10.6.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make: *** [out/host/darwin-x86/obj/EXECUTABLES/emulator_intermediates/emulator] Error 1

    Any ideas on how to resolve this errors.

  9. Hi! I got to the make part, but then I got this:
    MacBook-de-Eleonora:mydroid Eleonora$ make
    build/core/ *** faltando o separador. Pare.
    Which separator is it? Can anyone tell me how to put it there in the file so it’ll work?

  10. Hi,

    The link to the android source setup changed:


Leave a Reply