mac环境下android11源码编译
目的
本博客主要记录对于android11源码的下载及编译以及编译过程中出现的问题解决方法,最后对某芯片板子刷机,观察运行效果,期间对分区,fastboot配置项等会有相关研究记录。
工具配置
- jdk配置
- shell 环境切换至切换至bash (我默认采用的是zsh)
chsh -s /bin/bash
切换回zsh 如下还原即可
chsh -s /bin/zsh
源码下载(清华源镜像站)
-
配置repo工具
mkdir ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
-
修改repo的更新源,防止访问谷歌服务器更新repo
PATH=~/bin:$PATH
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
-
git配置信息
ps:没有使用过git及环境搭建的,这里配置下git
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
-
初始化仓库
$ repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-11.0.0_r30 --depth=1 --platform=auto
-b : 指定代码分支,这里只下载android11的r30版本
–depth: 只获取最新提交的commit相关信息,减少数据量 -
同步代码
repo sync -c
仅同步分支代码,其他分支信息不予同步
同步的过程中可能会出现各种诸如:
RPC failed : Curl xxx 54
RPC failed : SSL xxx
RPC failed: Curl xxx 9
网上很多方法都试过了都不行,后面换了网络环境之后多sync 2次就成功了,个人感觉还是网络环境问题。 -
编译:
编译x86-64android模拟器
source build/envsetup.sh
lunch aosp_x86_64_eng
make -j4
出现的问题:
6.1 存储空间不够导致中止,186G全部用完了,通过磁盘管理把其余分区多余的空间合进来一共360G
6.2. ld.lld: error: out/soong/.intermediates/frameworks/native/services/surfaceflinger/libsurfaceflinger/android_x86_64_shared/libsurfaceflinger.so: unknown file type
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
[ 81% 26726/32718] //libcore/mmodules/intracoreapi:art-module-intra-core-api-stubs-source metalava merged [common]
通过readelf -h libsurfaceflinger.so不是一个elf文件
通过file libsurfaceflinger.so 仅输出一个data
尝试直接rm这个so重新生成,现象还是一样
最终解决办法:
cd frameworks/native/
m clean
m -j4
这样就通过,整体还是比较顺利的。
其他Ubuntu20.04环境编译
后面使用Ubuntu 20.04也进行了编译遇到了编译错误:
FAILED: out/soong/build.ninjia
xxxx…xxxx
Killed
这个问题卡了很久,后面偶然发现监视器查询一旦编译到这里内存就消耗完了,编译线程被强行kill掉导致,本人电脑内存8G,然后通过扩大swap交换内存增加到16G后,编译通过。
参考链接:
https://blog.csdn.net/wzzduoji/article/details/108643141
https://blog.csdn.net/mvp_Dawn/article/details/107624203