想要自己基于aosp编译安卓系统,本质上需要:
-
确定好机型和版本
你是什么手机?要在手机上编译什么版本的安卓系统?查找当前机型的驱动文件?
-
系统初始化
在ubuntu中安装必备的工具和命令,例如:同步源码需要的git
-
同步aosp源码(下载代码)【耗时】
基于repo进行代码的同步(底层本质调用git同步代码)
-
安装依赖
编译aosp源码需要安装jdk8、xsltproc、fontconfig等
-
编译源码【耗时】
-
安装至手机系统
1.机型和版本
本篇示例:Pixel2XL + android8.1.0
- 官方包 https://developers.google.cn/android/images OPM2.171019.029
-
AOSP版 https://source.android.com/docs/setup/about/build-numbers OPM2.171019.029 android-8.1.0_r20
-
Piexl 2XL驱动 https://developers.google.cn/android/drivers OPM2.171019.029
2.系统初始化
-
Python软连接
sudo ln -s /usr/bin/python3.6 /usr/bin/python
-
git
sudo apt install git -y
git config --global user.name "wupeiqi" git config --global user.email "wupeiqi@live.com"
-
curl
sudo apt install curl -y
-
其他(可选)
sudo apt install net-tools openssh-server vim -y
3.同步源码
利用清华源去同步源码,国内主要是:清华源、中科大源(推荐清华)。
https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/
-
下载repo + 环境变量 + 可执行权限
mkdir ~/bin PATH=~/bin:$PATH curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo chmod a+x ~/bin/repo
-
环境变量
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
-
创建aosp文件夹目录(以后放在代码)
cd ~/bin mkdir aosp cd aosp
-
指定同步版本
repo init -u https://mirr