0x00 Automotive
AOSP中提供了编译不同产品的配置,如Phone,Automotive,TV等。当有需要时,可以分别去编译他们。下面介绍编译 编译Automotive(Car)可能遇到的问题。
0x01 Lunch Error
AOSP编译正常的流程为:
cd AOSP_ROOT_DIR
source build/envsetup.sh
lunch index or combo
当我们选择编译 Car(aosp_car_emu_x86_64-userdebug
or lunch 12
) 的时候,会报这样的错误:
ttdevs@ttdevs-pc:~/AOSP$ lunch 12
build/core/product_config.mk:227: *** Can not locate config makefile for product "aosp_car_emu_x86". Stop.
ttdevs@ttdevs-pc:~/AOSP$
Google了一下,这是一个排版错误,直接将_emu
去掉即可,即 lunch aosp_car_x86_64-userdebug
,其他平台类似。
下面简单分析下这个问题。
ttdevs@ttdevs-pc:~/AOSP$ source build/envsetup.sh
including device/asus/fugu/vendorsetup.sh
including device/generic/car/vendorsetup.sh
including device/generic/mini-emulator-arm64/vendorsetup.sh
including device/generic/mini-emulator-armv7-a-neon/vendorsetup.sh
including device/generic/mini-emulator-mips/vendorsetup.sh
including device/generic/mini-emulator-mips64/vendorsetup.sh
including device/generic/mini-emulator-x86/vendorsetup.sh
including device/generic/mini-emulator-x86_64/vendorsetup.sh
including device/generic/uml/vendorsetup.sh
including device/google/dragon/vendorsetup.sh
including device/google/marlin/vendorsetup.sh
including device/google/muskie/vendorsetup.sh
including device/google/taimen/vendorsetup.sh
including device/huawei/angler/vendorsetup.sh
including device/lge/bullhead/vendorsetup.sh
including device/linaro/hikey/vendorsetup.sh
including sdk/bash_completion/adb.bash
ttdevs@ttdevs-pc:~/AOSP$
根据上面日志,我们看一下 device/generic/car/vendorsetup.sh
这个文件和其所在的目录。
ttdevs@ttdevs-pc:~/AOSP/device/generic/car$ tree
.
|-- AndroidProducts.mk
|-- aosp_car_arm.mk
|-- aosp_car_arm64.mk
|-- aosp_car_x86.mk
|-- aosp_car_x86_64.mk
|-- common
| |-- android.hardware.dummy.xml
| |-- car.mk
| |-- car_core_hardware.xml
| |-- config.ini
| |-- manifest.xml
| `-- sepolicy
| |-- file_contexts
| |-- hal_vehicle_hwservice.te
| |-- hwservice.te
| |-- hwservice_contexts
| `-- system_app.te
`-- vendorsetup.sh
2 directories, 16 files
ttdevs@ttdevs-pc:~/AOSP/device/generic/car$
在 vendorsetup.sh
中,我们看到添加了四个 combo
,都是带 emu
的。在 AndroidProducts.mk
中可以看到分别加载了对应的四个 make
文件,这里以 aosp_car_x86_64.mk
为例:
$(call inherit-product, device/generic/car/common/car.mk)
$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_x86_64.mk)
PRODUCT_NAME := aosp_car_x86_64
PRODUCT_DEVICE := generic_x86_64
PRODUCT_BRAND := Android
PRODUCT_MODEL := Car on x86_64 emulator
PRODUCT_NAME
为 aosp_car_x86_64
并不是 aosp_car_emu_x86_64
。当我们执行 lunch aosp_car_emu_x86_64-userdebug
时,系统会去查找 aosp_car_emu_x86_64
这个 PRODUCT,找不到就报错了(别问我为什么是这个逻辑,我也说不清楚,RFSC)。至此,我们知道为什么删除 _emu
就可以了。为了验证这个逻辑,还可以选择下面的两个方案来解决这个问题:
-
/home/ttdevs/AOSP/device/generic/car/aosp_car_x86_64.mk
PRODUCT_NAME 改为:
PRODUCT_NAME := aosp_car_emu_x86_64
-
/home/ttdevs/AOSP/device/generic/car/vendorsetup.sh
添加:
add_lunch_combo aosp_car_x86_64-userdebug
大家可以尝试一下,这两种方法都可以。
0x02 Build Error
当上一个问题解决后,我们就可以开始编译了。很不幸,很快又会遇到另个问题:
Target buildinfo from: build/target/board/generic_x86_64/system.prop
error: ro.build.fingerprint cannot exceed 91 bytes: Android/aosp_car_x86_64/generic_x86_64:8.1.0/OPM6.171019.030.B1/ttdevs07021613:userdebug/test-keys (98)
[ 9% 7975/83700] Build hyb out/target/product/generic...b <- external/hyphenation-patterns/hu//hyph-hu.pat.txt
21515 unique nodes, 102669 total
ninja: build stopped: subcommand failed.
16:18:07 ninja failed with: exit status 1
简单搜索之后,Stackoverflow 给了我们答案,make 参数增加 BUILD_FINGERPRINT="custom_name"
,即:
make -j12 BUILD_FINGERPRINT="custom_name"
经过漫长的等待,我们就可以运行Car模拟器了~~
ulimit -S -n 2048