【源码编译】android-13.0.0_r7 for Pixel 4 on ubuntu20.04-server
【源码编译】android-12.1.0_r11 for Pixel 4 on ubuntu20.04-server
【源码编译】android-11.0.0_r46 for Pixel 4 on ubuntu20.04-server
【源码编译】android 10.0.0_r2 for Pixel 2 XL on ubuntu20.04-server
【源码编译】android-9.0.0_r46 for Pixel 2 XL on ubuntu20.04-server
【源码编译】android-8.0.0_r21 for Pixel 2 XL on ubuntu20.04-server
前言
感谢看雪,简书,CSDN等各个平台上的前辈的编译教程,感谢Google让android编译越来越简单,以前编译基本各种问题,现在直接一步到底,超级流畅
配置环境
- ubuntu20.04-server(已切换清华镜像)
- 4 core
- 8G RAM
- 2T disk
- 物理主机
- 必备代理,速度够快,建议20Mb/s以上
- Pixel 4 手机一部
- 配置proxychains
选择分支
这里我选择android-13.0.0_r7,因为这是支持Pixel 4的最新版本,并且支持的机型也比较多:pixel4 --pixel6。
注意:分支需要与设备型号匹配,并不是一个机型就可以通刷所有分支的,具体匹配列表参看:Here
下载源码
sudo apt-get update
sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5-dev lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig python
mkdir ~/bin
export PATH=~/bin:$PATH
proxychains curl https://storage.googleapis.com/git-repo-downloads/repo -o ~/bin/repo
chmod a+x ~/bin/repo
mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY
git config --global user.name Your Name
git config --global user.email you@example.com
# -b 后面代号选择,访问:https://source.android.com/setup/start/build-numbers#source-code-tags-and-builds
proxychains repo init -u https://android.googlesource.com/platform/manifest -b android-13.0.0_r7
# -j 的数字根据机器性能而定
proxychains repo sync -c -j8
android-13.0.0_r7 大约需要60G流量,耗时50分钟左右,平均网速20M/s
导入设备驱动(可选,刷入真实设备需要)
- 下载Pixel 4对应版本驱动文件,地址:TP1A.221005.002
- 将两个压缩包放入源码根目录
- 执行解压命令
tar -zxvf xxxxx.tgz
- 执行解压出的sh文件,一般是在
8.e.
条结束,在最后会让输入I ACCEPT
,不要回车太快,否则直接跳过去了 - 执行完后可在源码根目录下找到vector目录
配置jdk
android-8.1.0_r1之前需要自己安装jdk,之后源码里就自带了,路径:prebuilts/jdk,所以android-13.0.0_r7不需要配置jdk
构建源码
cd WORKING_DIRECTORY
sudo apt-get install libncurses5
export _JAVA_OPTIONS="-Xmx4g"
source build/envsetup.sh
lunch aosp_flame-userdebug
m
构建耗时:2小时33秒 (怎么还更快了,之前同样配置编译个android 8.0整整用了一下午还多)
这里循环执行m,报错就继续执行,有给修复提示,就按提示做,否则默认一直m,只要不是每次错误都一样。不过我这里编译没遇到任何问题,直接一步过,看来越新的版本,问题越少啊
刷入镜像
cd WORKING_DIRECTORY/out/target/product/flame/
fastboot flashall -w
刷入镜像(远程服务器编译,本地Window)(On Xshell 5)
- xshell下
cd WORKING_DIRECTORY/out/target/product/flame/
sz *.txt
sz *.img
- window下
切换到sz命令下载的目录,在该目录打开cmd,执行如下命令
set ANDROID_PRODUCT_OUT=./
fastboot flashall -w
参考
- https://source.android.com/setup/develop
- 下载编译安卓源码(Google)
- Android10源码定制(一) 制作完全Root版本
- AOSP系统签名的生成以及替换
- https://source.android.com/devices/tech/ota/sign_builds
- https://source.android.com/devices/bootloader/locking_unlocking?hl=zh-cn
- Android 7.1修改默认的休眠时间
- aosp 更改默认语言、时区问题
- SELinux政策文件
- 构建Pixel2内核
- 通过串口实时打印Android内核调试log信息
- adb如何打印kernel输出log
- 第3章 内核调试手段之内核打印
- http://www.juneleo.cn/47a3736f9762/
- [run_soong_ui] Error 1
- 源码编译(1)——Android6.0源码编译详解