分享

How to Setup Android Build Environment on OS X 10.9 Mavericks – Guide

 joy_chen 2014-01-09

If you are having a MAC which is loaded on the latest Mavericks OS, then you can now setup the Build environment easily. While this procedure won’t help you make the custom ROMs or the kernels, it will help you to create your Android development journey. So, with the help of some simple instructions you can setup this in your MAC. This build environment allows the developer to download the Android source code (ASC), which can then be used to create custom ROMs, themes, apps and almost everything else w.r.t the OS. Some of the components of the build environment includes Java Development Kit (JDK), theAndroid SDK & the Android source.

MavericksIconX

Procedure to Setup Android Build Environment on OS X 10.9 Mavericks:

Step 1:

Install X Code 5 in your MAC, preferably the latest version as it fixes most of the bugs.

Note: XCode is around 4GB and can be downloaded from the AppStore. Once downloaded, it will kick start the 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.

Step 2:

Now, install the Java JDK in your MAC. Just open the terminal and type in the java. If this is not installed, then you will be prompted to install the same.

Up next, to build Android you will be needing he JDK 6. Just click on the below mentioned link to download the .dmg file and install the same.

Java for OS X 2013-005

Step 3:

Now, after installing X Code, you need to install the Android SDK from android.com wensite. Please note that since the full SDK is not required, you can download the ADT Bundle along with the SDK tools packages are mentioned below;

AndroidSDK for Mac OS X – SDK Tools Only download
AndroidSDK for Mac OS X – FULL ADT BUNDLE

As soon as the SDK is installed successfully, you need to follow the below steps to install in your system with the help of terminal.

  • Extract the contents of AndroidSDK into a new folder, android-sdk
  • Create a new folder in HOME directory dubbed as Android [home directory can be found by opening Finder, and clicking on your username in the column to the left]
  • Move the Android-sdk folder to 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:

nano -w ~/Users/USERNAME/.bash_profile

This will open the bash.profile file from your home directory in the Nano Editor and enter the below mentioned commands in the terminal window;

export PATH=${PATH}:~/android/android-sdk/tools

export PATH=${PATH}:~/android/android-sdk/platform-tools

export PATH=${PATH}:~/bin

PATH=”$HOME/android/android-sdk/tools:$HOME/android/android-sdk/platform-tools:$PATH”

Bashprofile will point to the ~/android/android-sdk. You may choose to modify it so that it reflects exactly.

  • Right click on the terminal icon and select Quit for coming out of the terminal to pick up the changes made to .bash_profile,
  • Open terminal window,
  • 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,

Step 4.

  • This step takes care of Downloading and Installing Brew, and the Required Packages to Build Android
  • Once you have installed XCode and Java along with Android SDK tools, you now need to install the required tools for Android.
  • Now, you need to install Brew. Open the terminal and enter in the below mentioned commands;

ruby -e “$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)”

  • This will begin the download and installation of Brew. Again, depending on your hardware and internet connection, this could take a bit.
  • Once Brew is installed, add more things to the .bash_profile, Open that back up using Nano. If you don’t remember how to do that, please go back to Step #3 .
  • Once you are back into Nano and are editing the .bash_profile, enter the following on their own 2 lines:

touch ~/.bash_profile && echo “PATH=/usr/local/bin:/usr/local/sbin:$PATH:/usr/local/android-sdk/tools:/usr/local/android-sdk/platform-tools” >> ~/.bash_profile

export BUILD_MAC_SDK_EXPERIMENTAL=1

  • Once those lines are entered, save changes and exit Nano by pressing COMMAND X &  Y, then press ENTER.
  • 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 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.
  • Enter the following command into the Terminal:

brew install git coreutils findutils gnu-sed gnupg pngcrush repo python

ln -s /usr/local/bin/gfind /usr/local/bin/find && ln -s /usr/local/bin/gsed /u

Step 5:

  • Up next, enter the below mentioned commands in your terminal

brew install cpanm

sudo cpanm Switch –force

Step 6:

  • 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.

Enter the following into the Terminal.

hdiutil create -type SPARSE -fs “Case-sensitive Journaled HFS+” -size 60g -volname “android” -attach ~/Desktop/Android

  • Now, to access that volume via the Terminal, simply type:

cd /Volumes/android

and now you will be able to do something like, say, initialize the OmniROM Source:

cd /Volumes/android

mkdir omnirom

cd omnirom

repo init -u https://github.com/omnirom/android.git -b android-4.3

repo sync

Do let us know in the comments section or on out Facebook / Google+ Page if you face any issues.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多