Android源码编译报错:minibp因‘错误过多’触发panic
编译Android源码时minibp阶段panic: too many errors问题排查与解决
错误日志
[1/1] out/soong/.minibootstrap/minibp out/soong/.bootstrap/build.ninja FAILED: out/soong/.bootstrap/build.ninja out/soong/.minibootstrap/minibp -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/.bootstrap/build.ninja.d -o out/soong/.bootstrap/build.ninja Android.bp panic: too many errors goroutine 22 [running]: github.com/google/blueprint/parser.(*parser).error(0xc420285b80, 0x6c0a80, 0xc420288c20) build/blueprint/parser/parser.go:134 +0x317 github.com/google/blueprint/parser.(*parser).errorf(0xc420285b80, 0x696e73, 0x15, 0x0, 0x0, 0x0) build/blueprint/parser/parser.go:139 +0x75 github.com/google/blueprint/parser.newParser.func1(0xc420285b80, 0x696e73, 0x15) build/blueprint/parser/parser.go:115 +0x4f text/scanner.(*Scanner).error(0xc420285b80, 0x696e73, 0x15) /home/chaos/android_build/prebuilts/go/linux-x86/src/text/scanner/scanner.go:327 +0x2d1 text/scanner.(*Scanner).next(0xc420285b80, 0x0) /home/chaos/android_build/prebuilts/go/linux-x86/src/text/scanner/scanner.go:284 +0x3c9 text/scanner.(*Scanner).Peek(0xc420285b80, 0x268) /home/chaos/android_build/prebuilts/go/linux-x86/src/text/scanner/scanner.go:316 +0x4a text/scanner.(*Scanner).Scan(0xc420285b80, 0x0) /home/chaos/android_build/prebuilts/go/linux-x86/src/text/scanner/scanner.go:540 +0x2f github.com/google/blueprint/parser.(*parser).next(0xc420285b80) build/blueprint/parser/parser.go:156 +0x4f github.com/google/blueprint/parser.newParser(0x6c0c80, 0xc420272068, 0xc420214360, 0x68df3d) build/blueprint/parser/parser.go:119 +0x172 github.com/google/blueprint/parser.ParseAndEval(0xc420170840, 0x17, 0x6c0c80, 0xc420272068, 0xc420214360, 0x17, 0x0, 0x0, 0x415a28) build/blueprint/parser/parser.go:87 +0x43 github.com/google/blueprint.(*Context).parseOne(0xc4200a42c0, 0x68df3d, 0x1, 0xc420170840, 0x17, 0x6c0c80, 0xc420272068, 0xc420214360, 0xc420095a40, 0x50fd08, ...) build/blueprint/context.go:938 +0x21d github.com/google/blueprint.(*Context).openAndParse.func1(0x6c1660, 0xc420272068, 0xc42028ecd8, 0xc420911e58, 0xc4200a42c0, 0x68df3d, 0x1, 0xc420170840, 0x17, 0xc420214360, ...) build/blueprint/context.go:902 +0x120 github.com/google/blueprint.(*Context).openAndParse(0xc4200a42c0, 0xc420170840, 0x17, 0xc420214360, 0x68df3d, 0x1, 0xc420095a40, 0x0, 0x0, 0x0, ...) build/blueprint/context.go:903 +0x627 github.com/google/blueprint.(*Context).WalkBlueprintsFiles.func1.1(0xc4200a42c0, 0xc420095a40, 0x68df3d, 0x1, 0xc42001ede0, 0xc42001ed80, 0xc42001ee40, 0xc42001eea0, 0xc420094f90, 0xc420018430) build/blueprint/context.go:753 +0x84 created by github.com/google/blueprint.(*Context).WalkBlueprintsFiles.func1 build/blueprint/context.go:752 +0x293 ninja: build stopped: subcommand failed. 17:47:51 soong minibootstrap failed with: exit status 1
编译环境
Linux version 5.4.0-150-generic (buildd@bos03-amd64-012) Ubuntu 7.5.0-3ubuntu1~18.04, #167~18.04.1-Ubuntu, gcc version 7.5.0 openjdk version "9" OpenJDK Runtime Environment (build 9+181-android4627429) OpenJDK 64-Bit Server VM (build 9+181-android4627429, mixed mode
已做排查
- 检查近期修改的
.bp文件,未发现明显语法错误 - 尝试清理重建项目(
make clean && make),问题未解决
可能的解决办法
- 启用详细错误日志:编译时添加
SOONG_LOG_LEVEL=debug参数,比如执行SOONG_LOG_LEVEL=debug make,获取具体的.bp文件错误信息,避免直接触发panic。 - 单独解析可疑.bp文件:用minibp工具单独检查可疑文件,命令格式:
out/soong/.minibootstrap/minibp -t path/to/your/Android.bp,定位具体错误行。 - 检查字符编码与换行符:部分.bp文件可能包含非ASCII字符或Windows风格换行符(CRLF),导致扫描器出错。用
file path/to/Android.bp检查编码,dos2unix path/to/Android.bp转换换行符。 - 重新同步prebuilt Go:源码自带的prebuilt Go可能损坏,执行
repo sync prebuilts/go/linux-x86 -f重新同步。 - 重建Android.bp.list:删除
out/.module_paths/Android.bp.list后重新生成,或手动生成:find . -name Android.bp | sort > out/.module_paths/Android.bp.list。
内容的提问来源于stack exchange,提问作者Chao WANG
相关产品推荐
相关产品推荐

