AOSP编译问题

发布时间:2025-12-10 11:26:02 浏览次数:5

问题:未安装rsync

/bin/bash: line 1: rsync: command not found

解决:安装rsync

sudo pacman -S rsync

问题:默认情况在linux编译系统 会开启odex的。

Fault message: Check failed: map.IsValid() Failed anonymous mmap((nil), 131072, 0x3, 0x22, -1, 0): Cannot allocate memory. See process maps in the log.ERROR: Dex2oat failed to compile a boot image.It is likely that the boot classpath is inconsistent.Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" to see verification errors.04:07:58 ninja failed with: exit status 1#### failed to build some targets (13:29 (mm:ss)) ####

解决:编译前关闭dex2oat

export WITH_DEXPREOPT=false

问题:mke2fs参数导致

Creating regular file /data/aosp/out/soong/.temp/tmptQHrWf/content/apex_payload.imgInvalid filesystem option set: has_journal,extent,huge_file,flex_bg,metadata_csum,metadata_csum_seed,64bit,dir_nlink,extra_isize,orphan_fileAssertionError: Failed to execute: out/soong/host/linux-x86/bin/mke2fs -O ^has_journal -b 4096 -m 0 -t ext4 -I 256 -N 162 -U 7d1522e1-9dfa-5edb-a43e-98e3a4d20250 -E hash_seed=7d1522e1-9dfa-5edb-a43e-98e3a4d20250 /data/aosp/out/soong/.temp/tmptQHrWf/content/apex_payload.img 163M

解决:修改mke2fs的配置文件。

cp /etc/mke2fs.conf /etc/mke2fs.conf.bak #备份vim /etc/mke2fs.conf # 修改

将下面部分
ext4 = {
features = has_journal,extent,huge_file,flex_bg,metadata_csum,metadata_csum_seed,64bit,dir_nlink,extra_isize,orphan_file
}

修改为
ext4 = {
features = has_journal
}

后记:
开始以为是磁盘的xfs格式导致,后来利用Create a File Image Container or Filesystem in a File的方法测试后发现不是磁盘格式问题

测试步骤:用mke2fs制作img镜像文件

truncate --size=100M myfs.imgdd if=/dev/zero of=myfs.img count=204800sudo mkfs.ext4 myfs.imgsudo mke2fs -t ext4 myfs.img

问题:python版本不匹配

FAILED: out/target/product/generic_x86_64/system-qemu.img/bin/bash -c "(export SGDISK=out/host/linux-x86/bin/sgdisk SIMG2IMG=out/host/linux-x86/bin/simg2img; device/generic/goldfish/tools/mk_combined_img.py -i out/target/product/generic_x86_64/system-qemu-config.txt -o out/target/product/generic_x86_64/system-qemu.img)"File "/data/aosp/device/generic/goldfish/tools/mk_combined_img.py", line 48print "'%s' cannot be converted to int" % (line[2])^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?10:17:24 ninja failed with: exit status 1

解决:修改python为python2

sudo pacman -S python2 # 安装python2sudo ln -s /usr/bin/python2 /usr/bin/python

问题:编译期间改变了out目录导致报错

emulator: WARNING: Couldn't find crash service executable /data/aosp/prebuilts/android-emulator/linux-x86_64/emulator64-crash-serviceemulator: ERROR: No initial system image for this configuration!

解决:使用emulator -verbose查看详细报错信息,发现是由于使用export OUT_DIR=xx改变了目录,导致目录错乱。
使用evn查看当前环境变量,修改不正确的目录,例如下面,具体要看情况

export ANDROID_HOST_OUT=/data/aosp/out/host/linux-x86export ANDROID_PRODUCT_OUT=/data/aosp/out/target/product/generic_x86_64export ANDROID_HOST_OUT_TESTCASES=/data/aosp/out/host/linux-x86/testcases
需要做网站?需要网络推广?欢迎咨询客户经理 13272073477