Catalina編譯android 10報錯

Catalina編譯android 10報錯

環境

先聲明一下環境:

系統: macOS Catalina 10.15.3

aosp分支版本:android-10.0.0_r21

編譯目標版本:aosp_walleye-userdebug

當執行完編譯相關命令後,最終執行make -j16的時候,出現了異常:

編譯相關命令簡介:

source build/envsetup.sh
lunch 21
make -j16

異常一:系統不兼容

爲了方便大家遇到的時候能搜到這裏,我把整個異常的代碼都貼出來:

Superli-2:aosp superli$ make -j16
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=10
TARGET_PRODUCT=aosp_walleye
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=cortex-a73
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=cortex-a73
HOST_ARCH=x86_64
HOST_OS=darwin
HOST_OS_EXTRA=Darwin-19.3.0-x86_64-10.15.3
HOST_BUILD_TYPE=release
BUILD_ID=QQ1A.200105.002
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/google/wahoo vendor/google/camera hardware/google/pixel
============================================
[  0% 2/22868] build out/target/product/walleye/obj/ETC/sepolicy_tests_intermed
sepolicy_testsFAILED: out/target/product/walleye/obj/ETC/sepolicy_tests_intermediates/
/bin/bash -c "(out/host/darwin-x86/bin/sepolicy_tests -l out/host/darwin-x86/lib64/libsepolwrap.dylib 		 -f out/target/product/walleye/obj/ETC/plat_file_contexts_intermediates/plat_file_contexts  -f out/target/product/walleye/obj/ETC/vendor_file_contexts_intermediates/vendor_file_contexts  -p out/target/product/walleye/obj/ETC/sepolicy_intermediates/sepolicy ) && (touch out/target/product/walleye/obj/ETC/sepolicy_tests_intermediates/sepolicy_tests )"
/bin/bash: line 1: 47188 Segmentation fault: 11  ( out/host/darwin-x86/bin/sepolicy_tests -l out/host/darwin-x86/lib64/libsepolwrap.dylib -f out/target/product/walleye/obj/ETC/plat_file_contexts_intermediates/plat_file_contexts -f out/target/product/walleye/obj/ETC/vendor_file_contexts_intermediates/vendor_file_contexts -p out/target/product/walleye/obj/ETC/sepolicy_intermediates/sepolicy )
[  0% 3/22868] build out/target/product/walleye/obj/ETC/treble_sepolicy_tests_2
FAILED: out/target/product/walleye/obj/ETC/treble_sepolicy_tests_28.0_intermediates/treble_sepolicy_tests_28.0
/bin/bash -c "(out/host/darwin-x86/bin/treble_sepolicy_tests -l 		out/host/darwin-x86/lib64/libsepolwrap.dylib  -f out/target/product/walleye/obj/ETC/plat_file_contexts_intermediates/plat_file_contexts  -f out/target/product/walleye/obj/ETC/vendor_file_contexts_intermediates/vendor_file_contexts 		-b out/target/product/walleye/obj/ETC/built_plat_sepolicy_intermediates/built_plat_sepolicy -m out/target/product/walleye/obj/ETC/treble_sepolicy_tests_28.0_intermediates/28.0_mapping.combined.cil 		-o out/target/product/walleye/obj/ETC/treble_sepolicy_tests_28.0_intermediates/built_28.0_plat_sepolicy -p out/target/product/walleye/obj/ETC/sepolicy_intermediates/sepolicy 		-u out/target/product/walleye/obj/ETC/built_plat_sepolicy_intermediates/base_plat_pub_policy.cil ) && (touch out/target/product/walleye/obj/ETC/treble_sepolicy_tests_28.0_intermediates/treble_sepolicy_tests_28.0 )"
/bin/bash: line 1: 47187 Segmentation fault: 11  ( out/host/darwin-x86/bin/treble_sepolicy_tests -l out/host/darwin-x86/lib64/libsepolwrap.dylib -f out/target/product/walleye/obj/ETC/plat_file_contexts_intermediates/plat_file_contexts -f out/target/product/walleye/obj/ETC/vendor_file_contexts_intermediates/vendor_file_contexts -b out/target/product/walleye/obj/ETC/built_plat_sepolicy_intermediates/built_plat_sepolicy -m out/target/product/walleye/obj/ETC/treble_sepolicy_tests_28.0_intermediates/28.0_mapping.combined.cil -o out/target/product/walleye/obj/ETC/treble_sepolicy_tests_28.0_intermediates/built_28.0_plat_sepolicy -p out/target/product/walleye/obj/ETC/sepolicy_intermediates/sepolicy -u out/target/product/walleye/obj/ETC/built_plat_sepolicy_intermediates/base_plat_pub_policy.cil )
[  0% 4/22868] build out/target/product/walleye/obj/ETC/treble_sepolicy_tests_2
FAILED: out/target/product/walleye/obj/ETC/treble_sepolicy_tests_27.0_intermediates/treble_sepolicy_tests_27.0
/bin/bash -c "(out/host/darwin-x86/bin/treble_sepolicy_tests -l 		out/host/darwin-x86/lib64/libsepolwrap.dylib  -f out/target/product/walleye/obj/ETC/plat_file_contexts_intermediates/plat_file_contexts  -f out/target/product/walleye/obj/ETC/vendor_file_contexts_intermediates/vendor_file_contexts 		-b out/target/product/walleye/obj/ETC/built_plat_sepolicy_intermediates/built_plat_sepolicy -m out/target/product/walleye/obj/ETC/treble_sepolicy_tests_27.0_intermediates/27.0_mapping.combined.cil 		-o out/target/product/walleye/obj/ETC/treble_sepolicy_tests_27.0_intermediates/built_27.0_plat_sepolicy -p out/target/product/walleye/obj/ETC/sepolicy_intermediates/sepolicy 		-u out/target/product/walleye/obj/ETC/built_plat_sepolicy_intermediates/base_plat_pub_policy.cil ) && (touch out/target/product/walleye/obj/ETC/treble_sepolicy_tests_27.0_intermediates/treble_sepolicy_tests_27.0 )"
/bin/bash: line 1: 47190 Segmentation fault: 11  ( out/host/darwin-x86/bin/treble_sepolicy_tests -l out/host/darwin-x86/lib64/libsepolwrap.dylib -f out/target/product/walleye/obj/ETC/plat_file_contexts_intermediates/plat_file_contexts -f out/target/product/walleye/obj/ETC/vendor_file_contexts_intermediates/vendor_file_contexts -b out/target/product/walleye/obj/ETC/built_plat_sepolicy_intermediates/built_plat_sepolicy -m out/target/product/walleye/obj/ETC/treble_sepolicy_tests_27.0_intermediates/27.0_mapping.combined.cil -o out/target/product/walleye/obj/ETC/treble_sepolicy_tests_27.0_intermediates/built_27.0_plat_sepolicy -p out/target/product/walleye/obj/ETC/sepolicy_intermediates/sepolicy -u out/target/product/walleye/obj/ETC/built_plat_sepolicy_intermediates/base_plat_pub_policy.cil )
17:56:43 ninja failed with: exit status 1

#### failed to build some targets (21 seconds) ####

解決方案

該問題是因爲編譯腳本中的內容和Catalina系統不兼容,google已經出了官方補丁,補丁地址

要解決的同學,可以點進去看看,不過作爲一個唯飯博客,我會直接告訴你怎麼做。

用工具打開你的/system/sepolicy/Android.bp 這個文件,打開後長這樣:

    // libsepolwrap gets loaded from the system python, which does not have the
    // ASAN runtime. So turn off sanitization for ourself, and  use static
    // libraries, since the shared libraries will use ASAN.
    static_libs: [
        "libbase",
        "libsepol",
    ],
    stl: "libc++_static",
    sanitize: {
        never: true,
    },
}

stl: "libc++_static",刪除並保存即可。

然後再重新執行編譯就行了。

保險起見,你可以把另一個補丁也加上,補丁地址

用工具打開/build/soong/cc/config/x86_darwin_host.go,打開後長這樣:

	darwinSupportedSdkVersions = []string{
		"10.10",
		"10.11",
		"10.12",
		"10.13",
		"10.14",
	}

將它改爲:

	darwinSupportedSdkVersions = []string{
		"10.10",
		"10.11",
		"10.12",
		"10.13",
		"10.14",
		"10.15",
	}

我用過這兩個文件的修改後,編譯一次成功。但願你也是這樣。

刷機fastboot 無法識別設備

執行 fastboot -w flashall或者fastboot devices的時候,出現如下異常:

ERROR: Couldn't create a device interface iterator: (e00002bd)
ERROR: Couldn't create a device interface iterator: (e00002bd)
ERROR: Couldn't create a device interface iterator: (e00002bd)

原因也是fastboot 版本不兼容。

解決 我將fastboot 版本替換爲 26就可以了,如何更換? 去這個地址:platform-tools_r26.0.1, 下載解壓後,將一個名爲fastboot的可執行文件替換到你當前的fastboot目錄即可。

你可以通過 which fastboot看到你當前的fastboot地址。

找不到ROM位置

以上各種都解決完後,執行fastboot -w flashall刷機,出現找不到ROM位置的異常:

Superli-2:walleye superli$ fastboot -w flashall
error: neither -p product specified nor ANDROID_PRODUCT_OUT set
Superli-2:walleye superli$ 

或者說這種異常:

error: could not load android-info.txt

網上各種說法,都是讓你去配置ANDROID_PRODUCT_OUT或者指定-p參數,但是並沒有用。 如果你和我遇到的差不多,那可能是你當前的shell會話,沒有執行環境初始化。

解決:我因爲編譯完後,中途退出了shell,重新打開準備刷系統,結果報了這個錯。 只要重新初始化一下編譯環境就可以解決:

source build/envsetup.sh
lunch 21

執行完後,再去對應目錄刷系統,就可以成功了。``

差不多就這些了,Enjoy~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章