持续更新中...
1、文本解析错误
TOYBOX_VERSION awk: bailing out at source line 1
解决:使用gawk
替换awk
brew install gawk
2、MacOS SDK版本问题
在较新版本的mac系统下编译aosp可能会出现MAC_SDK_VERSION ${版本号} isn't supported ...
或者MAC_SDK_VERSION 10.13 is not installed
.
aosp所使用的sdk
版本一般都很低,这里为了编译通过我们需要下载旧版本的sdk
。
旧版本下载地址:https://github.com/phracker/MacOSX-SDKs
下载旧版本的sdk解压到/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
修改xcode的最低SDK支持版本
cp /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/info.plist ~/Downloads
编辑文件~/Downloads/info.plist
,将MinimumSDKVersion
的值改为10.11
,编辑完成后,再复制回去
推荐使用
vscode
进行编辑,需要安装扩展Binary Plist
sudo cp -f ~/Downloads/info.plist /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/info.plist
完成,最后编译时指定下sdk版本MAC_SDK_VERSION=10.13
即可:
MAC_SDK_VERSION=10.13 make -j8
如果需要自定义sdk版本的可以修改build/soong/cc/config/x86_darwin_host.go
文件,进行以下修改:
darwinSupportedSdkVersions = []string{
"10.10",
"10.11",
"10.12",
"10.13",
"10.14", // 新增
"10.15", // 新增
"11.0", // 新增
"11.1", // 新增
"11.3", // 新增
}
在最新版本的源代码中,官方已经开始支持11.0
和11.1
的版本:https://android.googlesource.com/platform/build/soong/+/refs/heads/master/cc/config/x86_darwin_host.go
3、SELinux问题
错误日志:
[ 0% 4/29298] build out/target/product/keyaki/obj/ETC/sepolicy_tests_intermediates/sepolicy_tests
FAILED: out/target/product/keyaki/obj/ETC/sepolicy_tests_intermediates/sepolicy_tests
/bin/bash -c "(out/host/darwin-x86/bin/sepolicy_tests -l out/host/darwin-x86/lib64/libsepolwrap.dylib -f out/target/product/keyaki/obj/ETC/plat_file_contexts_intermediates/plat_file_contexts -f out/target/product/keyaki/obj/ETC/vendor_file_contexts_intermediates/vendor_file_contexts -p out/target/product/keyaki/obj/ETC/sepolicy_intermediates/sepolicy ) && (touch out/target/product/keyaki/obj/ETC/sepolicy_tests_intermediates/sepolicy_tests )"
/bin/bash: line 1: 36384 Segmentation fault: 11 ( out/host/darwin-x86/bin/sepolicy_tests -l out/host/darwin-x86/lib64/libsepolwrap.dylib -f out/target/product/keyaki/obj/ETC/plat_file_contexts_intermediates/plat_file_contexts -f out/target/product/keyaki/obj/ETC/vendor_file_contexts_intermediates/vendor_file_contexts -p out/target/product/keyaki/obj/ETC/sepolicy_intermediates/sepolicy )
ninja: build stopped: subcommand failed.
00:08:06 ninja failed with: exit status 1
#### failed to build some targets (22 seconds) ####
类似
FAILED: build out/target/product/${设备名称}/obj/ETC/sepolicy_tests_intermediates/sepolicy_tests
这样开头的错误基本属于SELinux的异常
临时解决方案:
make SELINUX_IGNORE_NEVERALLOWS=true
但是只是临时方案,关闭了SELinux功能,但是发布aosp版本时是需要打开的
谷歌官方的方案:
https://android.googlesource.com/platform/system/sepolicy/+/1f944107a3341ab593c93bbdf09e22436cc0e3d3%5E%21/#F0
修改文件system/sepolicy/tests/Android.bp
,注释掉第14行的stl:"libc++_static",
@@ -11,7 +11,6 @@
"libbase",
"libsepol",
],
- stl: "libc++_static",
sanitize: {
never: true,
},