Hello everyone,
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
Code:/** * 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)
- repo
- Homebrew
- Many, many packages required for building Android
XCode
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.
Java
Android SDK
- 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
Homebrew
Code:ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
This will begin the download and installation of Brew.
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:
Code:brew outdated && brew update && brew upgrade && brew doctor
After running brew doctor, you should receive a message saying the follow: Your system is ready to brew.
Now, we can install the packages required to build Android.
Required Packages For Compiling Android
Enter the following command into the Terminal:
Code:brew install git coreutils findutils gnu-sed gnupg pngcrush python
This WILL take a while.
Repo
Open Terminal and enter the following:
Code: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.
Code:hdiutil create -type SPARSE -fs "Case-sensitive Journaled HFS+" -size 60g -volname "android" -attach ~/Desktop/Android
I have it set to be 60 GB here, but you can increase or decrease the size to whatever you choose, simply change the "60" to any number of GB you want it to be. I generally use 100 GB.
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:
Code:~/.bash_profile
Now copy / paste this into the terminal, so it's in the bash_profile you're creating:
Code: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
Save it by pressing Ctrl + X , then Ctrl + Y
Once back at the command line in Terminal, enter the following:
Code:source ~/.bash_profile
Necessary cherry-picks for OS X compatibility
That's it. Refer to your individual ROM source for how to sync the manifests and get builds going. Happy building!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!
build
https://github.com/CyanogenMod/android_build/commit/e04d4ddad4790a5f67d96873890cdc8230f0e18a
openssl / sha1sum errors?
https://github.com/CyanogenMod/android_build/commit/18c1d6d96df97b975b87a2736446c9dfd3ab4169
readink -f errors?
https://github.com/omnirom/android_build/commit/27e819cd6b6c44cbb86a0dc2bd3d735ad5dc09e7
sed/gsed errors that is NOT "sed: RE error: illegal byte sequence"?
https://github.com/omnirom/android_build/commit/24b9c1bfe07d24f7e2a425d9d5aae52fd30f3819
errors with the zip creation?
https://github.com/omnirom/android_build/commit/08c61654feff40eeec04eef40f4970408de1e229
JNI errors in /external/chromium_org ?
external_chromium_org
https://github.com/CyanogenMod/andr...mmit/5130af630390487b37d99941887883647c67f37a
Last edited: