Android源代码编译

Android源码下载及编译

使用科大镜像(国内无法直接访问google)

首先下载 repo 工具

1
2
3
4
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage-googleapis.lug.ustc.edu.cn/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

然后建立一个工作目录(名字任意)

1
2
mkdir AndroidSource
cd AndroidSource

初始化仓库:

1
2
3
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest
## 如果提示无法连接到 gerrit.googlesource.com,可以编辑 ~/bin/repo,把 REPO_URL 一行替换成下面的:
## REPO_URL = 'https://gerrit-googlesource.lug.ustc.edu.cn/git-repo'

下载特定的android源码版本

1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-4.0.1_r1

同步源码树

1
repo sync

可能需要漫长的等待android源码的下载

源码下载完成后,开始编译android源码

1
2
3
source build/envset.sh
lunch full-eng
make

简单的三步即可完成源码的编译