ToB企服应用市场:ToB评测及商务社交产业平台

标题: 编译Android14 AOSP纪录 [打印本页]

作者: 锦通    时间: 2024-10-16 22:24
标题: 编译Android14 AOSP纪录
AOSP编译
编译情况


事前预备

安装下载AOSP的依赖

  1. #安装git
  2. sudo apt-get install git
  3. #配置环境变量
  4. mkdir ~/bin
  5. PATH=~/bin:$PATH
  6. #安装cul
  7. sudo apt-get install curl
  8. #下载repo并设置权限:
  9. curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
  10. chmod a+x ~/bin/repo
  11. #安装python3
  12. sudo apt-get install python3
复制代码
安装编译AOSP的依赖

  1. #安装jdk
  2. sudo apt-get install openjdk-11-jdk
  3. #安装编译所需的依赖包
  4. sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig
复制代码
这里碰到个题目,因为使用的ubuntu24.04,找不到git-core,libncurses5,lib32ncurses5-dev,所以修改如下:

所以,最终使用如下命令安装依赖库。
  1. sudo apt-get install git gnupg flex bison build-essential zip curl zlib1g-dev libc6-dev-i386 libncurses6 lib32ncurses6 x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig
复制代码
因为我们安装的是libncurses6,找不到libncurses.so.5,在后续编译的时会出现如下错误
  1. error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
  2. 20:47:34 ninja failed with: exit status 1
复制代码
所以接纳符号链接,使用更高版本来代替。方式如下:
  1. find /usr -name "libtinfo.so.6"
  2. find /usr -name "libncurses.so.6"
复制代码
  1. #libtinfo.so.6 符号链接
  2. sudo ln -s /usr/lib/x86_64-linux-gnu/libtinfo.so.6 /usr/lib/x86_64-linux-gnu/libtinfo.so.5
  3. #libncurses.so.6 符号链接
  4. sudo ln -s /usr/lib/x86_64-linux-gnu/libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5
复制代码
  1. ls -l /usr/lib/x86_64-linux-gnu/libtinfo.so.5
  2. ls -l /usr/lib/x86_64-linux-gnu/libncurses.so.5
复制代码
下载AOSP

  1. mkdir android14
  2. cd android14
  3. repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-14.0.0_r28
  4. repo sync
复制代码
编译AOSP

选择想要编译的镜像,最开始我选择的是aosp_x86_64-eng,但是后续运行模拟器时会产生题目,建议加入sdk_phone_x86_64-eng,后使用sdk_phone_x86_64-eng举行编译。
  1. source build/envsetup.sh
  2. lunch //根据输出选择要编译的镜像编号
  3. make -j6
复制代码
编译阶段卡死

接纳ubuntu24.04虚拟机来编译aosp的,使用make直接编译最后阶段不知道为什么会卡死,清理编译缓存后,重新使用make -j6就编译乐成了。
运行模拟器

开启虚拟化

提示 ERROR | x86 emulation currently requires hardware acceleration
必要开启虚拟化,参考链接:https://blog.csdn.net/qq_44982815/article/details/111559823
缺少userdata-qemu.img

最开始编译的是aosp_x86_64-eng,编译乐成后,运行模拟器时提示缺少userdata-qemu.img,输出如下:
  1. Could not open '/root/aosp/out/target/product/generic_x86_64/userdata-qemu.img': No such file or directory
复制代码

  1. COMMON_LUNCH_CHOICES := \
  2.     aosp_arm64-eng \
  3.     aosp_arm-eng \
  4.     aosp_x86_64-eng \
  5.     aosp_x86-eng \
  6.     sdk_phone_x86_64-eng \
  7.     sdk_phone_arm64-eng \
复制代码
参考文章:
https://zhuanlan.zhihu.com/p/705716442
https://zhuanlan.zhihu.com/p/703829482
清理AOSP编译缓存,重新编译 sdk_phone_x86_64-eng

  1. #根目录
  2. source build/envsetup.sh
  3. make clobber
  4. #根目录
  5. make clean
  6. #kernel目录
  7. make mrproper
复制代码
模拟器运行乐成,但是黑屏

发现使用Android Studio的模拟器可以乐成运行,所以计划使用Android Studio运行编译出的镜像来运行模拟器。
  1. source ./build/envsetup.sh
  2. lunch sdk_phone_x86_64-eng
  3. make -j6 #如果已经编译成功无需再执行该条命令
  4. make emu_img_zip
  5. #完成后会输出镜像包的路径
复制代码

参考文章

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4