一、关于AOSP
1、AOSP(Android Open Source Project)是Google开放的Android 开源项目,中文官网为:
https://source.android.google.cn/
2、AOSP通俗来讲就是一个Android系统源码项目,通过它可以定制 Android 操作系统,国内手机厂商都是在此基础上开发的定制系统。因为墙的缘故,如果无法连接谷歌服务器获取AOSP源码,可以从 清华大学镜像站或者 中科大镜像。本篇文章以清华大学镜像站为例
二、下载 repo工具
1、安装 Git,在Ubuntu输入如下命令:
sudo apt-get install git
2、接下来创建bin,并加入到PATH中
mkdir ~/bin
PATH=~/bin:$PATH
3、安装curl库:
sudo apt-get install curl
4、下载repo并设置权限:
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod a+x ~/bin/repo
5、最后安装python,repo初始化时会用到:
sudo apt-get install python
6、重启虚拟机后,开始下载源码。
三、下载源码
1、建立工作目录
mkdir aosp
cd aosp
2、repo的运行过程中会尝试访问官方的git源更新自己,如果想使用tuna的镜像源进行更新,可以将如下内容复制到你的~/.bashrc里:
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
3、初始化仓库:
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
4、安装repo
apt install repo
5、初始化并指定版本:
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-9.0.0_r8
6、同步源码:
repo sync
转http://liuwangshu.cn/framework/aosp/2-download-aosp.html