1 基本信息:
- 虚拟机: VirtualBox 6.1
- ubuntu版本: 20
- Android版本: 10
版本选择: https://source.android.google.cn/setup/start/build-numbers?hl=zh-cn#source-code-tags-and-builds
当前最新的为Android11, 不选11,怕有坑,怕自己第一个跳
2 安装VirtualBox和ubuntu20:
详细安装过程,略过
2 Android 源码下载:
国内请使用清华大学镜像,参考: https://mirror.tuna.tsinghua.edu.cn/help/AOSP/
下面简述过程:
2.1 在用户目录下创建名为bin的目录:
mkdir ~/bin
PATH=~/bin:$PATH
后续讲repo 下载到该目录下,为了方便可以将其拷贝到你的PATH
里。
2.2 下载 repo 工具:
进入bin目录下载repo
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo
repo的运行过程中会尝试访问官方的git源更新自己,如果想使用tuna的镜像源进行更新,可以将如下内容复制到你的~/.bashrc
里
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
注: 配置repo时出现/usr/bin/env: ‘python’: No such file or directory, 因为ubuntu /usr/bin下默认安装的是python3, 所以找不到python, 执行 sudo apt-get install python 将安装python2
2.3 下载 Android镜像
参考文档:
- google中文社区: https://source.android.google.cn/setup/build/downloading?hl=zh-cn
- 清华Android镜像使用帮助: https://mirror.tuna.tsinghua.edu.cn/help/AOSP/
有两种方式:
- 使用每月更新的初始化包 (清华镜像推荐使用该方法)
由于首次同步需要下载约 30GB 数据,过程中任何网络故障都可能造成同步失败,所以首先使用初始化包进行初始化。 跳过
- 传统初始化方法
不走寻常路, 抱着试一下的态度,先试一下这种方式
初始化仓库:
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest
如果提示无法连接到 gerrit.googlesource.com,请参照git-repo的帮助页面的更新一节。
如果需要某个特定的 Android 版本(列表):
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-10.0.0_r41
同步源码树(以后只需执行这条命令来同步):
repo sync