Android14 AOSP源码编译

Android14 AOSP源码编译

环境要求

编译系统和内存要求

  • 内存至少16G
  • swap 至少32G

本次使用Ubuntu22版本

从 aosp 、清华源镜像等地方同步源码

百度网盘下载源码

安装依赖

在docker下编译(使用虚拟机或者直接物理机这步就别管了)

docker run -itd -v /downloads/chfs/test/android14/:/android14 --name ubuntu-test ubuntu

docker exec -it ubuntu-test /bin/bash

给镜像安装依赖

sudo apt update

# 下面依赖
sudo apt-get install python3 openjdk-11-jdk make bison g++-multilib gcc-multilib lib32ncurses-dev libncurses5 lib32z1-dev libxml2-utils unzip zip

开始执行

source build/envsetup.sh
lunch

# 也可以这样
# lunch aosp_x86_64-eng

# ubuntu 22编译需要执行下面的命令,否则会在过程中报错
python3 development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libcrypto

make -j4

在执行 lunch 时,会显示一个列表,根据需要选择自己要编译的系统类型,一般是 x86_64-eng

然后执行命令: make

tips: 编译过程出现问题最好执行 make clean ,否则会有奇怪的错误

internal error: bazel command failed: fork/exec ./build/bazel/bin/bazel: no such file or directory

输入 make 后等待执行完成即可。11代i3 6小时完成

生成Android14 iml 与 ipr 以供导入源码到 Android Studio

在已经成功编译源码到基础上。执行:

## 必须执行 mmm 生成 idegen.jar 文件
mmm development/tools/idegen/

development/tools/idegen/idegen.sh

错误记录:

[ 82% 144591/175254] //external/boringssl:libcrypto header-abi-diff libcrypto.so.abidiff
FAILED: out/soong/.intermediates/external/boringssl/libcrypto/android_vendor.34_x86_64_shared/libcrypto.so.abidiff
(prebuilts/clang-tools/linux-x86/bin/header-abi-diff -target-version current -allow-unreferenced-changes -allow-unreferenced-elf-symbol-changes -lib libcrypto -arch x86_64 -o out/soong/.intermediates/external/boringssl/libcrypto/android_vendor.34_x86_64_shared/libcrypto.so.abidiff -new out/soong/.intermediates/external/boringssl/libcrypto/android_vendor.34_x86_64_shared/libcrypto.so.lsdump -old prebuilts/abi-dumps/vndk/34/64/x86_64/source-based/libcrypto.so.lsdump)|| (echo 'error: Please update ABI references with: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libcrypto' && (mkdir -p $DIST_DIR/abidiffs && cp out/soong/.intermediates/external/boringssl/libcrypto/android_vendor.34_x86_64_shared/libcrypto.so.abidiff $DIST_DIR/abidiffs/) && exit 1)
******************************************************
error: libcrypto's ABI has EXTENDING CHANGES. Please check compatibility report at: out/soong/.intermediates/external/boringssl/libcrypto/android_vendor.34_x86_64_shared/libcrypto.so.abidiff
******************************************************
error: Please update ABI references with: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libcrypto
09:32:43 ninja failed with: exit status 1

#### failed to build some targets (06:11:00 (hh:mm:ss)) ####

解决方案(原文地址):执行命令:

python3 development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libcrypto

Copyright: 采用 知识共享署名4.0 国际许可协议进行许可

Links: https://zwc365.com/2024/01/06/android14aosp-yuan-ma-bian-yi

Buy me a cup of coffee ☕.