Android Framework之编译源码

环境

系统版本: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:未找到命令

这种情况大概率是编译环境出了问题,按照上面重新编译一遍即可

  1. 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
  1. 文件损坏问题
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
相关推荐
晓梦林2 小时前
cp520靶场学习笔记
android·笔记·学习
有味道的男人5 小时前
Open Claw对接1688平台
android·rxjava
_李小白6 小时前
【android opencv学习笔记】Day 17: 目标追踪(MeanShift)
android·opencv·学习
用户86022504674727 小时前
AI 分析头部APP系统优化框架
android
用户86022504674727 小时前
AI分析头部APP优化框架
android
2501_9160074710 小时前
iOS开发中抓取HTTPS请求的完整解决方法与步骤详解
android·网络协议·ios·小程序·https·uni-app·iphone
lvronglee12 小时前
【数字图传第四步】Android App查看图传视频
android·音视频
90后的晨仔12 小时前
Android 程序入口与核心组件详解
android
90后的晨仔13 小时前
Kotlin 简介与开发环境搭建
android
BU摆烂会噶13 小时前
【LangGraph】House_Agent 实战(四):预定流程 —— 中断与人工干预
android·人工智能·python·langchain