Home > Computer > Building Android on Snow Leopard

Building Android on Snow Leopard

September 24th, 2009 Simon Leave a comment Go to comments

In a break from writing about my life, I thought I’d give some Android developers out there a hand with a problem. Google don’t yet support the building of Android on OS 10.6 (Snow Leopard), but I managed to get it working. To do this, you’ll need to do four things:

  1. Install Rosetta
  2. Install JDK 1.5
  3. Install OS 10.4 support for XCode
  4. Change some gcc headers

First, install Rosetta from your Snow Leopard installation DVD. This allows you to run flex from the command line. Without this, a file in libwebcore won’t be generated correctly and you’ll get an error about a missing lex() symbol.

Second, install JDK 1.5. I found a guide online to do this. Instead of using update 4 as mentioned in the article, download the 1.5 JDK update 5 from apple.com: http://support.apple.com/downloads/Java_for_Mac…. Update: after doing this, change the current SDK version by using the Java Preferences utility in Applications->Utilities.

Third, download the XCode 3 package from Apple and install support for building for the OS 10.4 target.

Finally, you need to add symlinks from some OS 10.4 gcc includes to the 10.6 ones. This is fairly easy to figure out when building, but the ones I changed were all in /Developer/SDKs/MacOSX10.4u.sdk/usr/include and are as follows:

  • emmintrin.h -> /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/emmintrin.h
  • float.h -> /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/float.h
  • mm_malloc.h -> /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/mm_malloc.h
  • mmintrin.h -> /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/mmintrin.h
  • stdarg.h -> /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdarg.h
  • xmmintrin.h -> /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/xmmintrin.h

If you are building Android, then I am fairly certain I don’t need to tell you how to make symlinks.

Enjoy!

Update: in order to build the kernel, you’ll need to grab a copy of the elf.h header from Linux and copy it to /usr/local/include on your Mac. Comment out the #include <features.h>, otherwise you’ll get a compilation error.

Also, the following patches may be required on a 64 bit system:

Categories: Computer Tags:
  1. Pooba~
    October 24th, 2009 at 20:51 | #1

    and what else is new?

  2. November 8th, 2009 at 08:29 | #2

    Thanks so much for this great writeup. I have encountered a couple more errors in the process.

    1) The JDK5 installer from Apple would not work, it says that a newer package is already present. Is there other way to get the files from the package other then “launching” it?

    2) I started build with JDK5 from leopard instead and I am hitting the wall on some libs being compiled as 64bit (default architecture on SL) and not being found by other parts of the build process (specifically Could not load ‘clearsilver-jni’). Have you encountered this?

  3. November 8th, 2009 at 15:18 | #3

    @Jan (replying to myself)

    1) yes, there is a tool but generaly available JDK5 from leopard is enough

    2) you just have to se 64bit JDK5 as default JDK in Java Prefferences

    3) one more compilation issue I had was related to endians in yaffs2. this can be fixed by adding a default else branch to #ifdef HAVE_BIG_ENDIAN in mkyaffs2image.c

  4. absolutgcs
    November 8th, 2009 at 21:52 | #4

    very helpful, thanks!

  5. Philip
    November 24th, 2009 at 11:05 | #5

    Eh?

  6. Chris
    December 23rd, 2009 at 16:17 | #6

    PLEASE! PLEASE! PLEASE! help me.
    I have been trying everything I can find and did all the steps you guys listed here a few times but I keep getting the same error that I can NOT get around. Please if you have ANY idea what it is can you help me? I have tried changing my JDK to 6 (32 bit), JDK 6 (64 bit), JDK 5(32 bit), JDK 5 (64 bit) none of them seem to help. This is what I always get:

    I have done the steps here and installed 1.5 in its own dir:
    http://wiki.oneswarm.org/index.php/OS_X_10.6_Snow_Leopard

    drwxr-xr-x 9 root wheel 306 Feb 14 2009 1.5.0
    drwxr-xr-x 3 root wheel 102 Jul 20 17:35 1.3.1
    lrwxr-xr-x 1 root wheel 5 Dec 13 13:30 1.3 -> 1.3.1
    lrwxr-xr-x 1 root wheel 5 Dec 13 13:30 1.6 -> 1.6.0
    drwxr-xr-x 8 root wheel 272 Dec 16 10:45 1.6.0
    lrwxr-xr-x 1 root wheel 1 Dec 17 13:36 Current -> A
    drwxr-xr-x 9 root wheel 306 Dec 17 13:38 A
    lrwxr-xr-x 1 root wheel 1 Dec 17 13:49 CurrentJDK -> A
    lrwxr-xr-x 1 root wheel 5 Dec 22 00:01 1.5 -> 1.5.0

    ============================================
    PLATFORM_VERSION_CODENAME=Eclair
    PLATFORM_VERSION=Eclair
    TARGET_PRODUCT=generic
    TARGET_BUILD_VARIANT=eng
    TARGET_SIMULATOR=
    TARGET_BUILD_TYPE=release
    TARGET_ARCH=arm
    HOST_ARCH=x86
    HOST_OS=darwin
    HOST_BUILD_TYPE=release
    BUILD_ID=ECLAIR
    ============================================
    build/core/copy_headers.mk:15: warning: overriding commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h’
    build/core/copy_headers.mk:15: warning: ignoring old commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h’
    /bin/bash: line 0: cd: development/tools/layoutopt/app/src/resources: No such file or directory
    host C: libclearsilver-jni <= external/clearsilver/java-jni/j_neo_util.c
    external/clearsilver/java-jni/j_neo_util.c:2:17: error: jni.h: No such file or directory
    In file included from external/clearsilver/java-jni/j_neo_util.c:3:
    out/host/darwin-x86/obj/SHARED_LIBRARIES/libclearsilver-jni_intermediates/org_clearsilver_HDF.h:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘jlong’
    out/host/darwin-x86/obj/SHARED_LIBRARIES/libclearsilver-jni_intermediates/org_clearsilver_HDF.h:23: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
    out/host/darwin-x86/obj/SHARED_LIBRARIES/libclearsilver-jni_intermediates/org_clearsilver_HDF.h:31: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘jboolean’
    out/host/darwin-x86/obj/SHARED_LIBRARIES/libclearsilver-jni_intermediates/org_clearsilver_HDF.h:39: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘jboolean’
    external/clearsilver/java-jni/j_neo_util.c:431: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘jlong’
    external/clearsilver/java-jni/j_neo_util.c:440: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘jstring’
    external/clearsilver/java-jni/j_neo_util.c:453: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘jstring’
    external/clearsilver/java-jni/j_neo_util.c:466: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
    make: *** [out/host/darwin-x86/obj/SHARED_LIBRARIES/libclearsilver-jni_intermediates/j_neo_util.o] Error 1

    Thank you in advance for ANY help you can provide.
    -Chris

  7. Daniel
    December 28th, 2009 at 16:18 | #7

    As a side note, it seems there are formal patches in the works to fix build problems on 10.6. They’re in review at the moment but can still be manually applied if needed. See the following android-platform post for details. Particularly Chad Fawcett’s posts.

    http://groups.google.com/group/android-platform/browse_thread/thread/280869c238e290bb/c6e2f16afc911060?#c6e2f16afc911060

  8. Anonymous
    February 7th, 2010 at 11:12 | #8

    @Daniel
    Has there been any progress? I would love to help make this happen.

  9. capitain
    March 17th, 2010 at 04:02 | #9

    I think it’s impossible to make andorid project under SnowLeopard currently. the main reason is that the java vm 1.5 on snow leopard is mix mode which will generate 64bit jni lib, so the android can’t load it . All we have to do is just waiting

  10. Phil Krundle
    April 19th, 2010 at 03:05 | #10

    Hi Captain,
    It’s possible to make android project under Snow leopard.
    Check this link out.
    http://wp.me/pFB7D-bd

  11. Simon
    April 23rd, 2010 at 13:26 | #11

    @captain: it’s not impossible, because many people can do it, and these are the instructions to do so.

    @Jan: the page has a link to instructions for installing Java 1.5. Right, you can’t install the package directly but you must use the Pacifist tool. I haven’t encountered any other problems.