How to get the Android source code in Mac OS X

http://source.android.com/source/download.html

新增在 Mac OS X 底下, 取得 Android source code 的步驟方法

Mac OS X

To build the Android files in a Mac OS environment, you need an Intel/x86 machine running MacOS 10.4 (Tiger), 10.5 (Leopard), or 10.6 (Snow Leopard). The Android build system and tools do not support the obsolete PowerPC architecture.

Android must be built on a case-sensitive file system because the sources contain files that differ only in case. We recommend that you build Android on a partition that has been formatted with the journaled file system HFS+. HFS+ is required to successfully build Mac OS applications such as the Android Emulator for OS X.

Creating a case sensitive disk image

If you want to avoid partitioning/formatting your hard drive, you can use a case-sensitive disk image instead. To create the image, launch Disk Utility and select "New Image". A size of 8 GB is sufficient, or more if you prefer. Be sure to select "case sensitive, journaled" as the volume format.

This will create a .dmg file which, once mounted, acts as a drive with the required formatting for Android development. For a disk image named "android.dmg" stored in your home directory, you can add the following to your ~/.bash_profile to mount the image when you execute "mountAndroid":

# mount the android file image
function mountAndroid{ hdiutil attach ~/android.dmg-mountpoint /Volumes/android; }
Once mounted, you'll do all your work in the "android" volume. You can eject it (unmount it) just like you would with an external drive.

 

To set up your Mac OS development environment, follow these steps:

  1. Install XCode from http://developer.apple.com. We recommend version 3.0 or newer. If you are not already registered as an Apple developer, you will have to create an Apple ID in order to download.
  2. Install MacPorts from http://www.macports.org/.
  3. Make sure that /opt/local/bin appears in your path BEFORE /usr/bin. If not, add
    export PATH=/opt/local/bin:$PATH
    to your ~/.bash_profile.
  4. Get make, git, and GPG packages from port:
    $ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg
    If using Mac OS 10.4, also install bison:
    $ POSIXLY_CORRECT=1 sudo port install bison
  5. Temporary step: There is a bug in gmake 3.82 that prevents android from building. You can install version 3.81 using MacPorts by taking the following steps:

    Edit /opt/local/etc/macports/sources.conf and a line that says

    file:///Users/Shared/dports
    above the rsync line. Then create this directory:
    $ mkdir /Users/Shared/dports
    In the new dports directory, run Create a port index for your new local repository:
    $ portindex /Users/Shared/dports
    Finally, install the old version of gmake with
    $ sudo port install gmake @3.81

     

  6. Set an appropriate per-process file descriptor limit. To do this, add the following lines to your ~/.bash_profile:
    # set the number of open files to be 1024
    ulimit -S -n 1024

===

Checking build tools versions...
build/core/main.mk:70: ************************************************************
build/core/main.mk:71: You are building on a case-insensitive filesystem.
build/core/main.mk:72: Please move your source tree to a case-sensitive filesystem.
build/core/main.mk:73: ************************************************************
build/core/main.mk:74: *** Case-insensitive filesystems not supported.  Stop.