【android Framework 探究】android 13 aosp 全记录 - 编译

相关文章:【android Framework 探究】android 13 aosp 全记录 - 烧录

写在开始

自从关注Framework这一块儿,就有了自己编译aosp刷机的想法,模拟器当然是可以的,但是体验感还不能和真机想比,于是买一个二手piexl的想法就有了,根据预算选定piexl 5,支持最新的android 13,二手平台挑挑拣拣时间拉的有点长,不如中间就开始先编译好。

过程记录

断断续续利用下班和周末时间,终于编译成功了,下一步就等Piexl 5 到手刷机,今天把整个过程复盘一下,也记录下中间出现的错误和解决方式,方便以后查阅。

一,硬件环境

官网-要求 350G以上硬盘空间 + 16GB以上内存

我的

主机 -> Ubuntu 18.04.6 LTS (自己一直在用着)
内存 -> 16GB (thinkpad t440p ,又在网上买了两根8GB替换了之前的两根4GB)
硬盘 -> 350GB (凑这个删了不少东西)

强烈建议你提前把硬件升级,能省去不必要的麻烦,我原来8GB的内存,只要编译就能死机

二,软件环境

请根据你的Host主机,查询官网来安装所需的工具。
建立一个Linux构建环境

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

三,安装repo

1,mkdir ~/.bin
2,curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
3,chmod a+x ~/.bin/repo
4,sudo vim /etc/profile
添加下面两行

export PATH=~/.bin:$PATH
export REPO_URL=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/

5,source /etc/profile

四,配置Git用户

wu@wu-pc:~/.bin$ git config --global user.email "your [email protected]"
wu@wu-pc:~/.bin$ git config --global user.name "your name"

五,查看下要下载的分支

git clone https://aosp.tuna.tsinghua.edu.cn/platform/manifest
cd manifest/
git branch -a

在这里插入图片描述
查阅下官网,看看piexl 5支持的最新版本

源代码标签和构建

在这里插入图片描述

我们就下载最新的android-13.0.0_r12分支好了。

六,下载源代码

1,repo 初始化

repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-13.0.0_r12

2,下载源码

repo sync -j32

3,下载驱动

找到piexl 5对应的驱动文件
官网

在这里插入图片描述下载成功后,解压到aosp源码根目录。

tar -xvzf qcom-redfin-tp1a.221005.002-e7e20f49.tgz -C ~/GitProjects/aosp/
tar -xvzf google_devices-redfin-tp1a.221005.002-3daf7ea0.tgz  -C ~/GitProjects/aosp/

解压完成后,分别运行一下解压出的脚本。

./extract-qcom-redfin.sh 
./extract-google_devices-redfin.sh 

执行完,一直enter,大概在8-e处(一不小心就按过了),手动输入” I ACCEPT “ 同意条款。

七,编译

进入源码根目录:分别执行

1,source build/envsetup.sh

2,lunch

piex 5(redfin) 对应的版本:28. aosp_redfin-userdebug

Which would you like? [aosp_arm-eng]
Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-eng):

填28 ,按enter。

3,make

加不加-j参数,根据CPU性能决定,我的机器太老了,就没加,耗时11个半小时,最后艰难的成功了。
在这里插入图片描述

遇到的问题

1,下载源码报 “HTTP 503”

platform/external/glide:
fatal: unable to access ‘https://aosp.tuna.tsinghua.edu.cn/platform/external/glide/’: The requested URL returned error: 503
platform/external/glide: sleeping 4.0 seconds before retrying
error: RPC failed; HTTP 503 curl 22 The requested URL returned error: 503 Service Temporarily Unavailable
fatal: The remote end hung up unexpectedly

解决方法:repo脚本里面替换REPO_URL

 # REPO_URL = 'https://gerrit.googlesource.com/git-repo'
 REPO_URL = 'https://gerrit-google.tuna.tsinghua.edu.cn/git-repo'

2,下载源码报 “Downloading network changes failed”

error: Unable to fully sync the tree.
error: Downloading network changes failed.
Try re-running with “-j1 --fail-fast” to exit at the first error.

解决方法:晚上下,晚上下,晚上下… ,白天就是容易各种网络问题。

3,编译报错 “analyzing Android.bp files and generating ninja file at out/soong”

[ 98% 392/397] analyzing Android.bp files and generating ninja file at out/soong
FAILED: out/soong/build.ninja
cd “KaTeX parse error: Expected 'EOF', got '&' at position 49: …soong_build")" &̲& BUILDER="PWD/KaTeX parse error: Expected 'EOF', got '&' at position 50: …soong_build")" &̲& cd / && env -…BUILDER” --top “$TOP” --soong_out “out/soong” --out “out” -o out/soong/build.ninja --globListDir build --globFile out/soong/globs-build.ninja -t -l out/.module_paths/Android.bp.list --available_env out/soong/soong.environment.available --used_env out/soong/soong.environment.used.build Android.bp
Killed
00:31:16 soong bootstrap failed with: exit status 1

解决方法:1,保证16GB以上内存,加大Swap空间(我增加到了16G)(参考1参考2

猜你喜欢

转载自blog.csdn.net/lucky_tom/article/details/127825300