AOSP编译问题
问题:未安装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.img
Invalid filesystem option set: has_journal,extent,huge_file,flex_bg,metadata_csum,metadata_csum_seed,64bit,dir_nlink,extra_isize,orphan_file
AssertionError: 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.img
dd if=/dev/zero of=myfs.img count=204800
sudo mkfs.ext4 myfs.img
sudo 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 48
print "'%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 # 安装python2
sudo ln -sb /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-service
emulator: ERROR: No initial system image for this configuration!
解决:使用emulator -verbose查看详细报错信息,发现是由于使用export OUT_DIR=xx改变了目录,导致目录错乱。
使用evn查看当前环境变量,修改不正确的目录,例如下面,具体要看情况
export ANDROID_HOST_OUT=/data/aosp/out/host/linux-x86
export ANDROID_PRODUCT_OUT=/data/aosp/out/target/product/generic_x86_64
export ANDROID_HOST_OUT_TESTCASES=/data/aosp/out/host/linux-x86/testcases
问题:aidegen命令python版本不兼容
$ aidegen Settings -i s
MutableMapping = collections.MutableMapping
AttributeError: module 'collections' has no attribute 'MutableMapping'
解决:由于arch linux当前python版本是python3.10,从 python3.3开始,就使用 from collections.abc import MutableMapping 替代 from collections import Mapping, MutableMapping;
在 python3.10 上,彻底移除了 from collections import Mapping, MutableMapping。
yay -S python38 # 安装python3.8版本
ln -s /usr/bin/python3.8 /usr/bin/python3 #将python3指向python3.8