操作平台: ubuntu20.04
下载android系统源码:
1、参考清华软件源:https://mirrors.cnnic.cn/help/AOSP/
google repo:
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
或者
tsinghua 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'
2、两种下载方式:
(1)、下载月更新包。(体积比较大,包含多个版本)
wget -c 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代码
(2)、下载某个特定版本的源码。
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-11.0.0_r21
repo sync
# repo sync -j4
编译源码:
1、编译环境搭建
https://source.android.google.cn/docs/setup/build
# openjdk
apt install openjdk-11-jdk
# git-core
# gnupg
# flex
# bison
# build-essential
# zip
# curl
# zlib1g-dev
# gcc-multilib
# g++-multilib
# libc6-dev-i386
# libncurses5
# lib32ncurses5-dev
# x11proto-core-dev
# libx11-dev
# lib32z1-dev
# libgl1-mesa-dev
# libxml2-utils
# xsltproc
# unzip
# fontconfig
sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig
2、开始编译。
source build/envsetup.sh
lunch aosp_arm-eng
m -j4