Android操作系统编辑遇到的几个问题(TestGlobEscapes,module “xxx“ already defined/previous definition here)

近期在编辑Android12 操作系统遇到编译问题,特此记录原因及解决方法。

1. TestGlobEscapes失败:

现象日志:

FAILED: out/soong/.bootstrap/blueprint-pathtools/test/test.passed
out/soong/.bootstrap/bin/gotestrunner -p ./build/blueprint/pathtools -f out/soong/.bootstrap/blueprint-pathtools/test/test.passed -- out/soong/.bootstrap/blueprint-pathtools/test/test -test.short
--- FAIL: TestGlobEscapes (0.02s)
    --- FAIL: TestGlobEscapes/**/* (0.02s)
        glob_test.go:562: incorrect matches list:
        glob_test.go:562:  pattern: "**/*"
        glob_test.go:562:      got: []string{"a/", "b", "a/a"}
        glob_test.go:562: expected: []string{"*", "**/", "?", "a/", "b", "**/*", "**/a", "**/b/", "**/b/b", "a/a"}
        glob_test.go:562: incorrect deps list:
        glob_test.go:562:  pattern: "**/*"
        glob_test.go:562:      got: []string{".", "a"}
        glob_test.go:562: expected: []string{".", "**", "**/b", "a"}

原因分析: 

系统编译前会检查文件系统中特殊字符的支持情况,文件系统需要支持星号(*) 和问号(?)为文件名,检查自己源码对应目录下结构是否如下。

# tree build/blueprint/pathtools/testdata/escapes
escapes
├── *
├── **
│   ├── *
│   ├── a
│   └── b
│       └── b
├── ?
├── a
│   └── a
└── b

解决方法:

Android源代码需要放在Linux文件系统上(比如ext4, xfs等),如果放在了(或曾经拷贝到)ntfs/vfat等文件系统,则会造成特殊字符的文件名异常,造成以上编译失败现象。

使用正确的文件系统类型或重新按照以上建立目录结构即可。

2. 提示 'module "xxx" already defined/previous definition here'

现象日志:

 原因分析:

Android系统编译时禁止有相同模块名,以上提示也是有重复定义的模块。但原因也是因为曾将Android源代码用zip进行了压缩和解压缩,造成某些链接文件和目录变成真实的目录和文件。

* Andorid系统扫描模块名是会跳过链接目录。

解决方法:

压缩Android源代码目录时,不要使用zip,使用tar命令压缩为tgz文件可保留链接。

3. dex2oatd提示Cannot allocate memory

现象日志:

dex2oatd F 08-24 18:10:55 1781245 1781245 mem_map_arena_pool.cc:65] 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.

原因分析:

报错时对应执行的命令如下:

out/soong/host/linux-x86/bin/dex2oatd --avoid-storing-invocation --write-invocation-to=out/soong/roc_rk3588s_pc/dex_artjars/android/apex/art_boot_images/javalib/arm/boot.invocation --runtime-arg -Xms64m --runtime-arg -Xmx64m ......


其中-Xmx参数配置会影响dex优化时内存分配,在命令行中调整为512m能稳定编译通过(我这里比这个值小和大都大概率失败)。

解决方案:

方法1:修改配置文件调整内存大小

文件:build/target/product/default_art_config.mk:
配置:dalvik.vm.image-dex2oat-Xmx=64m (修改为512m)

方法2: 配置环境变量禁止优化,再重新编译(未尝试):

export WITH_DEXPREOPT=false

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值