Android 13 下载、源码编译
前言全局说明
Android 13 下载、源码编译
一、说明
1.1 环境:
Ubuntu 18.04.6 LTS (Linux qt-vm 5.4.0-150-generic #167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux)
1.2 清华源
AOSP清华源:https://mirrors.tuna.tsinghua.edu.cn/
AOSP帮助:https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/
1.3 Android 版本列表
https://developer.baidu.com/article/details/3248112
1.4 repo工具下载
https://mirrors.tuna.tsinghua.edu.cn/help/git-repo/
1.5 Google 官方推荐要求
https://source.android.com/setup/build/requirements?hl=zh-cN
1.6 Android系统支持设备查询:
https://source.android.com/setup/start/build-numbers?hl=zh-cn#source-code-tags-and-builds
1.7 Android设备驱动下载:
https://developers.google.com/android/drivers?hl=zh-cn
1.8 repo详细命令
http://doc.yonyoucloud.com/doc/wiki/project/android-source/using-repo.html
二、下载工具
因为官方源,国内访问不通畅,所以改用国内源
2.1 安装 git 工具
sudo apt install git
2.2 下载 repo 工具
git clone https://gerrit-googlesource.lug.ustc.edu.cn/git-repo
或
(推荐)
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo
三、下载 AOSP
3.1 准备 repo 工具
mkdir ~/aosp
cp repo ~/aosp
进入上面下载的 git-repo 目录,复制 repo 文件,到你想下载AOSP源码目录
3.2 临时,修改为清华源
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
3.3 初始化 repo仓库和切换分支
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-13.0.0_r7
根据官网,选择需要的分支版本
3.3 同步全部源码
repo sync -c -j4
-j4:4个线程下载,越多越快。但用清华源,官方建议选4, 太高会503
ctrl + z 后台下载,不影响其他使用
四、编译
android 源码下载完成后。
4.1 生效环境
source build/envsetup.sh
或者:
. build/envsetup.sh
4.2 选择目标平台
lunch
如果知道对应数字可以直接 lunch [数字]
4.3 编译
make
或
make -j6
或
make -j$(nproc)
-j后面是线程数,越多越多快,但最大数字和CPU内核数有关系
$(nproc) 是自定获取内核数量
4.4 需要详细编译信息:
make V=1
4.5 编译成功
会显示绿色提示。
编译时间根据机器配置不一样。
4.6 编译结果:
最后,会在out目录下,生成后缀为 *.img 的文件,根据需要刷入板子。
另:generic_arm64 是更具 lunch 时选项不同,名字也会不同
五、其他
5.1 构建Framework
make framework
免责声明:本号所涉及内容仅供安全研究与教学使用,如出现其他风险,后果自负。
参考、来源:
https://www.cnblogs.com/Terry-Liu/p/17408329.html
https://blog.csdn.net/wangguchao/article/details/127448175
https://blog.csdn.net/Sqq_yj/article/details/136684996
https://www.cnblogs.com/Terry-Liu/p/17408329.html
https://www.cnblogs.com/Terry-Liu/p/17408329.html
https://blog.csdn.net/fanged/article/details/136667315
https://developer.baidu.com/article/details/3248112 (4.3 5.1)
https://www.bilibili.com/video/BV1Xb4y1P7hc/?vd_source=5c2b3f8973a7142edcd392291a47e5ca
https://blog.51cto.com/u_16099323/7718087 (收集刷机、设备驱动下载)