环境
系统版本:Ubuntu 20.04
内存:32G
硬盘:1T
Android版本:Android10
开发环境搭建
bash
sudo apt-get update
sudo apt-get upgrade
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 python
下载repo工具
bash
mkdir ~/bin
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/bin/repo chmod +x
~/bin/repo
bash
git config --global user.email "xxxxxxxx@exmple.com"
git config --global user.name "UserNmae"
mkdir aosp
cd aosp
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-10.0.0_r41
repo sync
编译
bash
source build/envsetup.sh
lunch aosp_x86_64-eng
#亲测j4即可、j16
make -j4

到这里就算编译成功啦
bash
emulator -verbose -cores 4 -show-kernel
问题集
1.模拟器启动失败
输入emulator -verbose -cores 4 -show-kernel命令后出现
bash
emulator:未找到命令
这种情况大概率是编译环境出了问题,按照上面重新编译一遍即可
- Clang编译器崩溃报错
输入make -j16命令后出现
bash
clang++: error: unable to execute command: Segmentation fault (core dumped)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
解决方法:减少并行任务
bash
make -j4
- 文件损坏问题
bash
FAILED: ninja: out/soong/build.ninja:1569065: unexpected NUL byte
descrIption =
^ near here
00:17:56 ninja failed with: exit status 1
解决方法:删除相关文件并重新生成
bash
rm -rf out/
# 重新构建系统
source build/envsetup.sh
lunch aosp_x86_64-eng
make -j4