# mount the android file image
function mountAndroid { hdiutil attach ~/android.dmg -mountpoint /Volumes/android; }
# unmount the android file image
function umountAndroid() { hdiutil detach /Volumes/android; }
二、Installing required packages
Install MacPorts from macports.org
直接下载MacPorts_xxx.pkg文件安装即可(xxx为版本号)。
Note: Make sure that /opt/local/bin appears in your path before /usr/bin。可以通过$ echo $PATH命令查看。如果不是,在~/.bash_profile文件中添加下面代码,添加完毕后直接执行$ source ~/.bash_profile命令。
解压。将下载得到的aosp-latest.tar压缩文件直接拷贝到前面创建的xxx.dmg镜像文件装载的磁盘目录,执行$ tar xf aosp-latest.tar,稍等解压完毕后,当前目录会出现一个AOSP文件夹,该文件夹下有一个隐藏文件夹.repo。
同步代码树。执行$ repo sync。具体可以参考下面步骤:
wget https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # 下载初始化包
tar xf aosp-latest.tar
cd AOSP # 解压得到的 AOSP 工程目录
# 这时 ls 的话什么也看不到,因为只有一个隐藏的 .repo 目录
repo sync # 正常同步一遍即可得到完整目录
# 或 repo sync -l 仅checkout代码
四、Build
Clean up
To ensure the newly installed binaries are properly taken into account after being extracted, delete the existing output of any previous build using:
$ make clobber
报错
Error: could not find jdk tools.jar at /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/../lib/tools.jar, please check if your JDK was installed correctly. Stop.
Buildtype
Use
user
limited access; suited for production
userdebug
like "user" but with root access and debuggability; preferred for debugging
eng
development configuration with additional debugging tools
可选的有aosp_arm-eng、 aosp_arm64-eng、aosp_mips-eng、aosp_mips64-eng、aosp_x86-eng......
Build the code
$ make -jN
N为数字,一般为cpu线程数1到2倍。我的本本是mbp2015年中,使用$ make -j8,很多warning,不管即可,用了一个多小时,最后输出结果#### make completed successfully (01:06:05 (hh:mm:ss)) ####