I've come across, and been asked, a lot of questions regarding how to properly setup a build environment on OS X, so I'm going to make this guide on how to setup a build environment on OS X 10.9 Mavericks.
this is only for setting up the build environment, and since most ROMs use different configurations, you will need to refer to your specific ROM for how to initialize their source and build
Setting Up an Android Build Environment on OS X 10.9 Mavericks
A Word To The Wise
/** * if you don't follow my instructions exactly as they are written, several things will happen: * 1 - If you don't know what you're doing, it won't work * 2 - I won't respond with help, since everything you need IS RIGHT HERE **/
What You Will Be Installing:
- XCode 5
- Android SDK (includes ADB and Fastboot)
- Many, many packages required for building Android
XCode is roughly a 4 GB download from the AppStore. Once it is downloaded, it will start an installation process, where it will download more software and install XCode on your system. Depending on your hardware, and your internet speeds, this could take a long time.
Apple XCode 5 for OS X 10.9 Mavericks
Or just search for "XCode" in the App Store
Once XCode is downloaded and installed, you can pretty much forget about it. Just don't uninstall it.
- Extract the contents of the Android SDK download archive to a new folder and name it android-sdk
- Create a new folder in your HOME directory ( ~/ ) named android [your home directory can be found by opening Finder, and clicking on your username in the column to the left]
- Move the android-sdk folder INTO the android folder you just made in your Home directory ( it will be ~/android/android-sdk )
- Using Finder, navigate to the android/android-sdk/tools folder.
- Double-click the "android" file and go through the installer for Android SDK
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
Depending on your hardware and internet connection, this could take a bit.
Now, we need to run a few commands through Brew, just to make sure everything is installed correctly. Enter the following into the Terminal:
brew outdated && brew update && brew upgrade && brew doctor
Now, we can install the packages required to build Android.
Required Packages For Compiling Android
Enter the following command into the Terminal:
brew install git coreutils findutils gnu-sed gnupg pngcrush python
Open Terminal and enter the following:
mkdir -p ~/.bin curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo
Creating A Case-Sensitive Volume
We need to create a CASE-SENSITIVE image for our development. Android cannot be build on case-insensitive images, so we need to make one.
Enter the following into the Terminal.
hdiutil create -type SPARSE -fs "Case-sensitive Journaled HFS+" -size 60g -volname "android" -attach ~/Desktop/Android
Once the command is done, you will see a new .img on your desktop, called android.sparseimage. This is the volume you just created that will store your source. To mount it, you just simply double-click it.
Setting Up bash_profile
Enter the following into Terminal:
export PATH=~/bin:$PATH export PATH=~/android/android-sdk/sdk/platform-tools:$PATH export PATH=/usr/local/bin:$PATH export BUILD_MAC_SDK_EXPERIMENTAL=1 export LC_CTYPE=C export LANG=C
Once back at the command line in Terminal, enter the following:
Necessary cherry-picks for OS X compatibility
Here is a list of commits, organized alphabetically by repository, that you will need to cherry-pick in order to ensure the best compatibility for building on OS X:
If you come across other commits related to building on OS X that I have not listed, PLEASE respond to the thread and mention me. I'll get them added!
openssl / sha1sum errors?
readink -f errors?
sed/gsed errors that is NOT "sed: RE error: illegal byte sequence"?
errors with the zip creation?
JNI errors in /external/chromium_org ?