修改了android framework下的代码之后(修改/增加/删减函数),编译可能会碰到如下 error:
[ 50% 5221/10249] //frameworks/av/media/libstagefright/foundation:libstagefright_foundation header-abi-diff libstagefright_foundation.so.abidiff
FAILED: out/soong/.intermediates/frameworks/av/media/libstagefright/foundation/libstagefright_foundation/android_vendor.31_arm_armv7-a-neon_shared/libstagefright_foundation.so.abidiff
(prebuilts/clang-tools/linux-x86/bin/header-abi-diff -allow-unreferenced-changes -allow-unreferenced-elf-symbol-changes -lib libstagefright_foundation -arch arm -o out/soong/.intermediates/frameworks/av/media/libstagefright/foundation/libstagefright_foundation/android_vendor.31_arm_armv7-a-neon_shared/libstagefright_foundation.so.abidiff -new out/soong/.intermediates/frameworks/av/media/libstagefright/foundation/libstagefright_foundation/android_vendor.31_arm_armv7-a-neon_shared/libstagefright_foundation.so.lsdump -old prebuilts/abi-dumps/vndk/31/64/arm_armv7-a-neon/source-based/libstagefright_foundation.so.lsdump)|| (echo 'error: Please update ABI references with: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libstagefright_foundation' && (mkdir -p $DIST_DIR/abidiffs && cp out/soong/.intermediates/frameworks/av/media/libstagefright/foundation/libstagefright_foundation/android_vendor.31_arm_armv7-a-neon_shared/libstagefright_foundation.so.abidiff $DIST_DIR/abidiffs/) && exit 1)
******************************************************
error: VNDK library: libstagefright_foundation's ABI has EXTENDING CHANGES Please check compatibility report at: out/soong/.intermediates/frameworks/av/media/libstagefright/foundation/libstagefright_foundation/android_vendor.31_arm_armv7-a-neon_shared/libstagefright_foundation.so.abidiff
******************************************************
error: Please update ABI references with: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libstagefright_foundation
看到这么一串error可能有许多同学会不知所措了,但是我们静下心来阅读一下报错信息很容易就能猜到为什么会发生这个错误了。
首先是 libstagefright_foundation’s ABI has EXTENDING CHANGES,libstagefright_foundation.so 这个lib除了system会使用外,vendor也会使用,所以我们猜测类似的这种vendor/system 共用的 lib 会有一个兼容性检查,类似于 HIDL 兼容性矩阵。
提示中的 EXTENDING CHANGES 说明是有增加的内容,那如何解决这个问题呢?
报错信息中已经给了我们提示:
执行下面这个命令就好了
$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libstagefright_foundation
但是但是但是,可能执行以上命令后又有新的error出现了:
error: device/xxx/proprietary/libs/xxxx/Android.bp:1:1: module "xxxx" variant "android_vendor.31_arm_armv7-a-neon_static": module "xxxx" is not a shared library
11:33:01 soong bootstrap failed with: exit status 1
Traceback (most recent call last):
File "/home/xxxx/android/development/vndk/tools/header-checker/utils/create_reference_dumps.py", line 217, in <module>
main()
File "/home/xxxx/android/development/vndk/tools/header-checker/utils/create_reference_dumps.py", line 208, in main
num_processed = create_source_abi_reference_dumps_for_all_products(args)
File "/home/xxxx/android/development/vndk/tools/header-checker/utils/create_reference_dumps.py", line 154, in create_source_abi_reference_dumps_for_all_products
make_libs_for_product(args.libs, product, args.build_variant,
File "/home/xxxx/android/development/vndk/tools/header-checker/utils/create_reference_dumps.py", line 36, in make_libs_for_product
make_libraries(product, variant, vndk_version, targets, libs)
File "/home/xxxx/android/development/vndk/tools/header-checker/utils/utils.py", line 163, in make_libraries
lsdump_paths = read_lsdump_paths(product, variant, vndk_version, targets,
File "/home/xxxx/android/development/vndk/tools/header-checker/utils/utils.py", line 252, in read_lsdump_paths
make_targets(product, variant, [lsdump_paths_file_path])
File "/home/xxxx/android/development/vndk/tools/header-checker/utils/utils.py", line 153, in make_targets
subprocess.check_call(make_cmd, cwd=AOSP_DIR)
File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['build/soong/soong_ui.bash', '--make-mode', '-j', 'TARGET_PRODUCT=aosp_arm', 'TARGET_BUILD_VARIANT=userdebug', 'out/target/product/generic/lsdump_paths.txt']' returned non-zero exit status 1.
接下来要怎么办呢,冷静!
我们看报错信息的最后一行:TARGET_PRODUCT=aosp_arm,这个不是我们的目标Product呀!我们应该怎么指定Product呢?
添加参数 -h 就可以看到帮助信息了,
$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -h
usage: create_reference_dumps.py [-h] [--version VERSION] [--no-make-lib] [--llndk] [-libs LIBS] [-products PRODUCTS]
[--build-variant BUILD_VARIANT] [--compress] [-ref-dump-dir REF_DUMP_DIR]
optional arguments:
-h, --help show this help message and exit
--version VERSION VNDK version
--no-make-lib no m -j lib.vendor while creating reference
--llndk the flag is deprecated and has no effect
-libs LIBS libs to create references for
-products PRODUCTS products to create references for
--build-variant BUILD_VARIANT
build variant to create references for
--compress compress reference dump with gzip
-ref-dump-dir REF_DUMP_DIR
directory to copy reference abi dumps into
我们很容易就会知道用 -products 就可以指定参数了。
最后执行以下命令,执行完成后再编译就不会报错了:
$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libstagefright_foundation -products XXXXX