记录了在Mac10.12.5 系统上下载清华和科大源的AOSP 源码,并编译适用于Nexus5 的 Android 6.0.1 系统的过程。
环境
MAC 10.12.5
准备编译Android 6.0 版本,因为我有Nexus5,而N5 二进制包Google 提供的最新版本如下:
M4B30Z android-6.0.1_r77
下载源码
repo 下载
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
## 如果上述 URL 不可访问,可以用下面的:
## curl https://storage-googleapis.proxy.ustclug.org/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
清华大学Android 底包下载:
wget https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # 下载初始化包
tar xf aosp-latest.tar
源码同步
重新初始化一下,更改分支:
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-6.0.1_r77
更改成科大源:(更改文件 .repo/manifests.git/config)
https://aosp.tuna.tsinghua.edu.cn/platform/manifest 替换成 git://mirrors.ustc.edu.cn/aosp/platform/manifest
同步源码:
repo sync
二进制文件下载
Nexus5 二进制文件下载: https://developers.google.com/android/drivers#hammerhead
之后解压到源码树根目录,然后执行自解压脚本
编译环境配置
-
安装homeBrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-
安装 curl --with-openssl
brew install curl --with-openssl
然后配置PATH 将curl 的路径设置在系统默认的前面
export PATH=$(brew --prefix curl)/bin:$PATH -
JDK 7 下载安装
http://www.oracle.com/technetwork/java/javase/archive-139210.html
安装好后不用设置环境变量 -
MacOSX10.11.sdk 下载安装:
https://github.com/phracker/MacOSX-SDKs
下载解压然后拷贝到:/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
修改
build/core/combo/mac_version.mk
文件中如下行,可以一直添加到10.12
mac_sdk_versions_supported := 10.6 10.7 10.8 10.9 10.10 10.11 10.12
编译
由于之前有解压二进制包,先执行:
make clobber
然后
```source build/envsetup.sh
lunch
选择 `19. aosp_hammerhead-userdebug`
编译:`make`
## 编译成功
Creating filesystem with parameters:
Size: 1073741824
Block size: 4096
Blocks per group: 32768
Inodes per group: 8192
Inode size: 256
Journal blocks: 4096
Label: system
Blocks: 262144
Block groups: 8
Reserved block group size: 63
Created filesystem with 1704/65536 inodes and 105718/262144 blocks
Install system fs image: out/target/product/hammerhead/system.img
out/target/product/hammerhead/system.img+out/target/product/hammerhead/obj/PACKAGING/recovery_patch_intermediates/recovery_from_boot.p maxsize=1096212480 blocksize=135168 total=417841026 reserve=11083776
\e[0;32m#### make completed successfully (01:50:38 (hh:mm:ss)) ####\e[00m
## 镜像刷机
adb reboot fastboot
cd out/target/product/hammerhead/
fastboot flash boot boot.img
fastboot flash system system.img
fastboot reboot
网友评论