Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,733,293 Members 38,858 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE] Setting Up A Build Environment on OS X 10.9 Mavericks

Tip us?
 
jakew02
Old
(Last edited by jakew02; 3rd May 2014 at 02:03 AM.)
#1  
Recognized Developer / Recognized Contributor - OP
Thanks Meter 2309
Posts: 2,063
Join Date: Mar 2011
Location: Philadelphia
Info 2 [GUIDE] Setting Up A Build Environment on OS X 10.9 Mavericks


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
Quote:
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:
Quote:
  • XCode 5
  • Android SDK (includes ADB and Fastboot)
  • repo
  • Homebrew
  • Many, many packages required for building Android


XCode
Quote:
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
Quote:

  • 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
Quote:
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
Quote:
Enter the following command into the Terminal:
Code:
brew install git coreutils findutils gnu-sed gnupg pngcrush python
This WILL take a while.


Repo
Quote:
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
Quote:
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
Quote:
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
Quote:
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/andro...0cdc8230f0e18a

openssl / sha1sum errors?
https://github.com/CyanogenMod/andro...46c9dfd3ab4169

readink -f errors?
https://github.com/omnirom/android_b...3d735ad5dc09e7

sed/gsed errors that is NOT "sed: RE error: illegal byte sequence"?
https://github.com/omnirom/android_b...aae52fd30f3819

errors with the zip creation?
https://github.com/omnirom/android_b...4970408de1e229

JNI errors in /external/chromium_org ?
external_chromium_org
https://github.com/CyanogenMod/andro...7883647c67f37a
That's it. Refer to your individual ROM source for how to sync the manifests and get builds going. Happy building!
The Following 36 Users Say Thank You to jakew02 For This Useful Post: [ Click to Expand ]
 
fzr-r4
Old
#2  
fzr-r4's Avatar
Senior Member
Thanks Meter 75
Posts: 425
Join Date: Sep 2010
Location: Berkeley
This is amazing. Thank you so much!
The Following User Says Thank You to fzr-r4 For This Useful Post: [ Click to Expand ]
 
nazforex
Old
(Last edited by nazforex; 1st December 2013 at 06:59 PM.) Reason: additional comments
#3  
Senior Member
Thanks Meter 65
Posts: 566
Join Date: Oct 2009

 
DONATE TO ME
I get the following error everytime:

Code:
Creating filesystem with parameters:
    Size: 13725835264
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8144
    Inode size: 256
    Journal blocks: 32768
    Label: 
    Blocks: 3351034
    Block groups: 103
    Reserved block group size: 823
Created filesystem with 11/838832 inodes and 93654/3351034 blocks
+ '[' 0 -ne 0 ']'
stat: cannot read file system information for `%z': No such file or directory
/bin/bash: File: "/Volumes/android/omni/out/target/product/hammerhead/userdata.img"
    ID: 100000600000011 Namelen: *       Type: hfs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 39237622   Free: 18393164   Available: 18393164
Inodes: Total: 39237620   Free: 18393164
+
0 : syntax error in expression (error token is ": "/Volumes/android/omni/out/target/product/hammerhead/userdata.img"
    ID: 100000600000011 Namelen: *       Type: hfs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 39237622   Free: 18393164   Available: 18393164
Inodes: Total: 39237620   Free: 18393164
+
0 ")
make: *** [/Volumes/android/omni/out/target/product/hammerhead/userdata.img] Error 1
make: *** Deleting file `/Volumes/android/omni/out/target/product/hammerhead/userdata.img'
make: *** Waiting for unfinished jobs....

real	8m50.579s
user	1m9.360s
sys	0m46.059s
I get this building Omni but I don't get it building CM11
Any idea?
 
fzr-r4
Old
(Last edited by fzr-r4; 4th December 2013 at 10:55 PM.)
#4  
fzr-r4's Avatar
Senior Member
Thanks Meter 75
Posts: 425
Join Date: Sep 2010
Location: Berkeley
Default installing repo

for others using this awesome guide, don't forget to install repo in terminal the following commands before initializing repo

$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ cd ~/bin
$ curl http://commondatastorage.googleapis....downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
 
jakew02
Old
#5  
Recognized Developer / Recognized Contributor - OP
Thanks Meter 2309
Posts: 2,063
Join Date: Mar 2011
Location: Philadelphia
Quote:
Originally Posted by fzr-r4 View Post
for others using this awesome guide, don't forget to install repo in terminal the following commands before initializing repo

$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ cd ~/bin
$ curl http://commondatastorage.googleapis....downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
repo should be installed with brew, no need to download the binary from google although, i may be wrong
The Following 2 Users Say Thank You to jakew02 For This Useful Post: [ Click to Expand ]
 
joneidy
Old
#6  
joneidy's Avatar
Junior Member
Thanks Meter 6
Posts: 25
Join Date: Feb 2011
Quote:
Originally Posted by jakew02 View Post
repo should be installed with brew, no need to download the binary from google although, i may be wrong
Hello everyone, I`m getting the following error when trying to build Kitkat. If any help is given it will be greatly appreciated.

Code:
ldldld:::   warning:warning warning: directory:directory   notdirectory  notfoundnot   foundforfound   foroptionfor   'option-option Lout '/'-host-LoutLout///darwinhost-host/x86/darwin/darwin--objx86x86///libobjobj/'/lib
lib'ld'
:
ld ld:warning::   warningwarning:option:   -options option-  is-s  sobsoleteis   obsoleteandis   andbeing obsoletebeing   ignoredandignored
 
ldbeingld:  :ignoredunknown 
 unknownoptionld :option :-:  O2-unknown
O2 
option: -O2
collect2: ld returned 1 exit status
collect2: ld returned 1 exit status
collect2: ld returned 1 exit status
make: *** [out/host/darwin-x86/obj/EXECUTABLES/validatekeymaps_intermediates/validatekeymaps] Error 1
make: *** Waiting for unfinished jobs....
make: *** [out/host/darwin-x86/obj/EXECUTABLES/acp_intermediates/acp] Error 1
make: *** [out/host/darwin-x86/obj/EXECUTABLES/aidl_intermediates/aidl] Error 1
 
fzr-r4
Old
#7  
fzr-r4's Avatar
Senior Member
Thanks Meter 75
Posts: 425
Join Date: Sep 2010
Location: Berkeley
Default case-sensitive output directory/volume

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:

export OUT_DIR_COMMON_BASE=YOUR-VOLUME-AND-DESTINATION-HERE


Sent from my Nexus 5 using Tapatalk 4
 
joneidy
Old
#8  
joneidy's Avatar
Junior Member
Thanks Meter 6
Posts: 25
Join Date: Feb 2011
Default Another Build Error

Now I`m getting the following error, does anyone knows if I can just manually create the missing directory to skip the error?
Thanks in advance.

Code:
host C: libbz <= external/bzip2/bzlib.c
Import includes file: out/host/darwin-x86/obj/EXECUTABLES/bsdiff_intermediates/import_includes
host C++: validatekeymaps <= frameworks/base/tools/validatekeymaps/Main.cpp
host StaticLib: libinput (out/host/darwin-x86/obj/STATIC_LIBRARIES/libinput_intermediates/libinput.a)
host StaticLib: libutils (out/host/darwin-x86/obj/STATIC_LIBRARIES/libutils_intermediates/libutils.a)
host StaticLib: libcutils (out/host/darwin-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a)
host C: acp <= build/tools/acp/acp.c
host StaticLib: liblog (out/host/darwin-x86/obj/STATIC_LIBRARIES/liblog_intermediates/liblog.a)
host Executable: aidl (out/host/darwin-x86/obj/EXECUTABLES/aidl_intermediates/aidl)
host StaticLib: libhost (out/host/darwin-x86/obj/STATIC_LIBRARIES/libhost_intermediates/libhost.a)
host C++: aapt <= frameworks/base/tools/aapt/AaptAssets.cpp
host C++: aapt <= frameworks/base/tools/aapt/Command.cpp
host C++: aapt <= frameworks/base/tools/aapt/CrunchCache.cpp
host C++: aapt <= frameworks/base/tools/aapt/FileFinder.cpp
host C++: aapt <= frameworks/base/tools/aapt/Main.cpp
host C++: aapt <= frameworks/base/tools/aapt/Package.cpp
host C++: aapt <= frameworks/base/tools/aapt/StringPool.cpp
ld: warning: directory not found for option '-Lout/host/darwin-x86/obj/lib'
ld: warning: option -s is obsolete and being ignored
ld: unknown option: -O2
collect2: ld returned 1 exit status
make: *** [out/host/darwin-x86/obj/EXECUTABLES/aidl_intermediates/aidl] Error 1
make: *** Waiting for unfinished jobs....
 
fzr-r4
Old
(Last edited by fzr-r4; 11th December 2013 at 06:21 AM.)
#9  
fzr-r4's Avatar
Senior Member
Thanks Meter 75
Posts: 425
Join Date: Sep 2010
Location: Berkeley
sigh . . . Paranoid Android 4 completes a build for me on Mavericks, but root and wi-fi are broken. Terminal and Solid Explorer also don't work.

just putting this out there as a data point in case others try building PA on OS X.

EDIT:

i noticed that Symlink lines such as:

Symlink: /volumes/teamusb/output/android/target/product/hammerhead/system/xbin/rdev -> busybox

or

Symlink: /volumes/teamusb/output/android/target/product/hammerhead/system/bin/du -> toolbox

are resulting in those files (/system/xbin/rdev or /system/bin/du) being created in my .zip file, whereas a successful build from another user does not have those files.

this seems to be part of my problem--anyone have any guidance or similar issues?
 
matrixzone
Old
#10  
matrixzone's Avatar
Senior Member
Thanks Meter 740
Posts: 2,331
Join Date: Mar 2012
Thanks for this guide!!
If this is helpful or useful, please hit "Thanks" and its free

Tags
apple, compile android from source, mac, mavericks, os x
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes