[GUIDE] Setting Up A Build Environment on OS X 10.9 Mavericks
I've come across, and been asked, a lot of questions regarding how to properly setup a build environment on OS X 10.9 Mavericks. Since the release of 10.9 Mavericks, Apple deprecated some stuff from perl, which is giving people errors. I'm going to make this guide on how to setup a build environment on OS X 10.9 Mavericks.
Setting Up an Android Build Environment on OS X 10.9 Mavericks
1. Installing the necessary Applications from the Apple App Store
Android requires many packages and Command Line tools that are not native to Apple operating systems. To obtain some of the tools we will need, we will need to download and install XCode. XCode can be found on the supplementary software cd that came with your iMac or Macbook(pro), depending which type of computer you have. If you do not have access to that cd, then you can simply install it from the AppStore, or click the link below.
**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.
Once you have fully installed XCode, you will need to install the AndroidSDK, from Google. I am including the link to the SDK Tools Only download, since the full SDK is NOT required. IF you would like the full SDK, then by all means, please download it from the link below. The AndroidSDK can be obtained from the following link:
Once the SDK is downloaded, follow the steps below to install it to your system for easy access in the terminal. I am writing these steps per the setup that I personally use, and have found to be simple and effective. You may change the directory that you save the SDK files to, but you will need to reflect that within your .bash_profile.
Extract the contents of the AndroidSDK to a new folder, named 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
Open Terminal [this is easily achieved by holding COMMAND and pressing SPACEBAR, then typing TERM and hitting ENTER
Enter the following command into the Terminal:
This will open the .bash_profile file from you home directory in the Nano editor. Enter the following into Nano:
Notice that the /bash_profile will now point to ~/android/android-sdk. IF you decided to store your android-sdk folder somewhere else, this where you need to modify it, so that it reflects where exactly your android-sdk folder is located.
Doing this will allow you to access any of the commands from within the android-sdk folder, even if you are not located in that folder with the Terminal. Basically, you can use adb and fastboot without having to navigate to the folder containing them with the Terminal
Once you have finished adding the necessary lines to .bash_profile hold COMMAND and press X. Then press Y, then ENTER to save your changes. Nano will automatically quit back to the Terminal once you have saved.
"Right-Click on the Terminal icon and choose to Quit, the terminal must be restarted so that it picks up the changes made to .bash_profile
Open the Terminal again
Type "android" without quotation marks
The AndroidSDK installer will start
Click the checkbox next to Tools, and make sure that all sub items of Tools are checked.
Click Install X packages to the bottom right of the window
Click Tools in the window to the left, then click the radio button to accept the license
Click Install, and allow it to install the SDK Tools
4. Downloading and Installing Brew, and the Required Packages to Build Android
So, now we've successfully installed XCode, the PROPER version of Java, and the AndroidSDK. Now we need to install the tools required to build Android.
Now, many of these tools are "Linux-Only" and aren't available on Mac. Big Deal. We have an awesome thing called Brew. Brew allows you to install packages "command-line-style" just like on Linux. It's basically Mac's "apt-get".
So, to install Brew, open the Terminal, and enter the following:
This WILL take a while. Once complete, go ahead and move on to Step #5.
5. Fixing Switch.pm Issues
With this, YMMV, I completely re-did my build environment recently and did not have problems with Switch.pm, so you can probably skip this for now and come back later if you need to.
When upgrading to OS X Mavericks, Apple made some perl module deprecated, but we still need them to build Android!
The module in question is Switch.pm. If you follow this guide, but skip this step, you will get errors complaining about Switch.pm , and think "what is that?"
Well, it's a missing module that perl is calling on. To add it back, simply enter the following into Terminal:
brew install cpanm
sudo cpanm Switch --force
And you'll be good to go
6. Initializing the repo
Now that XCode, the AndroidSDK, java, and brew are installed. 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.
I have it set to be 60 GB with that specific line, 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 120+ 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. To mount it, you just simply double-click it.
Now, to access that volume via the Terminal, simply type:
and now you will be able to do something like, say, initialize the OmniROM Source:
repo init -u https://github.com/omnirom/android.git -b android-4.4
And there ya go! This guide should have gotten you from a regular installation of Mac OS X 10.9 Mavericks, to one that can build Android ROMs from source!
I did not include ROM-specific setup, since many of the ROMs that can be compiled from source maintain different processes for each. You should be able to follow this guide, and then find a guide on how to build the ROM of your choice from source, but IN THE ROM-SPECIFIC GUIDE you can skip down to "Initializing Repo"
PLEASE feel free to post any questions / comments / etc. as a reply to this thread, or send me a Private Message.
building Paranoid Android using the team's script for the build itself after syncing, I had to specify the output directory first, out I got an error saying I was building on a case-insensitive system:
XDA Developers was founded by developers, for developers. It is now a valuable resource for people who want to make the most of their mobile devices, from customizing the look and feel to adding new functionality. Are you a developer?