最近修改Android接口,报了一个VNDK的错误,如下
按照提示执行development/vndk/tools/header-checker/utils/create_reference_dumps.py -l android.hardware.gnss@1.0。执行不通过,报了如下错误:
$ development/vndk/tools/header-checker/utils/create_reference_dumps.py -l android.hardware.gnss@1.0
Traceback (most recent call last):
File "development/vndk/tools/header-checker/utils/create_reference_dumps.py", line 224, in <module>
main()
File "development/vndk/tools/header-checker/utils/create_reference_dumps.py", line 210, in main
targets = [Target(True, product), Target(False, product)]
File "development/vndk/tools/header-checker/utils/create_reference_dumps.py", line 29, in __init__
self.arch = build_vars[1]
IndexError: list index out of range
这个报错是因为环境的错误。
执行一下ls -l /bin/sh,查看用的是什么来解释执行Python脚本。
$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 4月 2 2019 /bin/sh -> dash
我本地的用dash来解释执行Python脚本,所以报错了,得用bash。
执行sudo dpkg-reconfigure dash指令可以切换成bash。
继续执行,发现还是报错了!如下
$ development/vndk/tools/header-checker/utils/create_reference_dumps.py -l android.hardware.gnss@1.0
Removing reference dumps...
removing /platform/prebuilts/abi-dumps/vndk/28/32/arm_armv7-a-neon/source-based/android.hardware.gnss@1.0.so.lsdump.gz
removing /platform/prebuilts/abi-dumps/ndk/28/32/arm_armv7-a-neon/source-based/android.hardware.gnss@1.0.so.lsdump.gz
making libs for product: aosp_arm_ab
Traceback (most recent call last):
File "development/vndk/tools/header-checker/utils/create_reference_dumps.py", line 224, in <module>
main()
File "development/vndk/tools/header-checker/utils/create_reference_dumps.py", line 215, in main
make_libs_for_product(args.libs, args.llndk, product)
File "development/vndk/tools/header-checker/utils/create_reference_dumps.py", line 97, in make_libs_for_product
make_libraries(libs, product, llndk_mode)
File "/platform/development/vndk/tools/header-checker/utils/utils.py", line 146, in make_libraries
make_targets(lib_targets, product)
File "/platform/development/vndk/tools/header-checker/utils/utils.py", line 137, in make_targets
stderr=subprocess.STDOUT)
File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['build/soong/soong_ui.bash', '--make-mode', '-j', 'android.hardware.gnss@1.0.vendor', 'TARGET_PRODUCT=aosp_arm_ab']' returned non-zero exit status 1
看到making libs for product: aosp_arm_ab这行,这个是因为我的项目product名字不一样导致的,加上参数-product product_name即可,product_name是你的项目的product名称。
$ development/vndk/tools/header-checker/utils/create_reference_dumps.py -l android.hardware.gnss@1.0 -product product_name
Removing reference dumps...
removing platform/prebuilts/abi-dumps/vndk/28/64/arm_armv8-a/source-based/android.hardware.gnss@1.0.so.lsdump.gz
removing /platform/prebuilts/abi-dumps/ndk/28/64/arm_armv8-a/source-based/android.hardware.gnss@1.0.so.lsdump.gz
removing /platform/prebuilts/abi-dumps/vndk/28/64/arm64_armv8-a/source-based/android.hardware.gnss@1.0.so.lsdump.gz
removing /platform/prebuilts/abi-dumps/ndk/28/64/arm64_armv8-a/source-based/android.hardware.gnss@1.0.so.lsdump.gz
making libs for product: product_name
Creating dumps for target_arch: arm and variant armv8-a
Created abi dump at /platform/prebuilts/abi-dumps/vndk/28/64/arm_armv8-a/source-based/android.hardware.gnss@1.0.so.lsdump.gz
Creating dumps for target_arch: arm64 and variant armv8-a
Created abi dump at /platform/prebuilts/abi-dumps/vndk/28/64/arm64_armv8-a/source-based/android.hardware.gnss@1.0.so.lsdump.gz
msg: Processed 2 libraries in 2.388603063424428 minutes
终于编译过了。更新了android.hardware.gnss@1.0.so.lsdump.gz文件。