MacでAndroidのソースをビルド

公式サイト

1. ビルド環境の設定

ディスクイメージの作成

$ hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 30g ~/android.sparseimage
ホームディレクトリに android.sparseimage ファイルができる。

以下を .bashrc なり .zshrc なりに追加。


# mount the android file image
function mountAndroid { hdiutil attach ~/android.sparseimage -mountpoint /Volumes/android; }
function unmountAndroid { hdiutil detach /Volumes/android; }

# set the number of open files to be 1024
ulimit -S -n 1024

export PATH=~/bin:$PATH # 2.ソースの取得参照

設定を反映させる。


$ source ~/.bashrc(~/.zshrc)

GPGをインストール


$ brew install gnupg

2. ソースの取得

Repoのインストール


$ mkdir ~/bin
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

ソース取得


$ mountAndroid
$ cd /Volumes/android
$ mkdir src # このディレクトリ名は任意
$ cd src
$ repo init -u https://android.googlesource.com/platform/manifest
$ repo sync
ブランチを指定したい場合は repo init で -bオプションを使用する(e.g. -b android-4.0.1_r1)。

3. ビルド

シェルはbashが推奨されている。

$ source build/envsetup.sh
$ lunch full-eng # DeviceとBuildtypeによってターゲットを指定
$ make -j4