最近公司的产品平台升级,芯片厂商换了,Android版本也由原来的Android 9 升级到了Android 12;
Audio模块要求支持支持多通道录音,于是在源码里新增了几个音频通道常量的定义,包括Audio的java层和hal层,主要新增的文件如下:
frameworks/base/media/java/android/media/AudioFormat.java
public static int inChannelMaskFromOutChannelMask(int outMask) throws IllegalArgumentException {
if (outMask == CHANNEL_OUT_DEFAULT) {
throw new IllegalArgumentException(
"Illegal CHANNEL_OUT_DEFAULT channel mask for input.");
}
switch (channelCountFromOutChannelMask(outMask)) {
case 1:
return CHANNEL_IN_MONO;
case 2:
return CHANNEL_IN_STEREO;
/**add by *** mic start**/
case 8:
return CHANNEL_IN_08;
case 12:
return CHANNEL_IN_12;
case 16:
return CHANNEL_IN_16;
/**add by *** mic end**/
default:
throw new IllegalArgumentException("Unsupported channel configuration for input.");
}
}
system/media/alsa_utils/alsa_device_profile.c
system/media/audio/include/system/audio-hal-enums.h
hardware/libhardware/modules/usbaudio/audio_hal.c
API增加完之后编译报错 1:
[ 83% 111200/133076] //system/media/audio_utils:libaudioutils header-abi-diff libaudioutils.so.abidiff
FAILED: out/soong/.intermediates/system/media/audio_utils/libaudioutils/android_vendor.31_arm64_armv8-a_shared/libaudioutils.so.abidiff
(prebuilts/clang-tools/linux-x86/bin/header-abi-diff -allow-unreferenced-changes -allow-unreferenced-elf-symbol-changes -lib libaudioutils -arch arm64 -o out/soong/.intermediates/system/media/audio_utils/libaudioutils/android_vendor.31_arm64_armv8-a_shared/libaudioutils.so.abidiff -new out/soong/.intermediates/system/media/audio_utils/libaudioutils/android_vendor.31_arm64_armv8-a_shared/libaudioutils.so.lsdump -old prebuilts/abi-dumps/vndk/31/64/arm64_armv8-a/source-based/libaudioutils.so.lsdump)|| (echo 'error: Please update ABI references with: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libaudioutils' && (mkdir -p $DIST_DIR/abidiffs && cp out/soong/.intermediates/system/media/audio_utils/libaudioutils/android_vendor.31_arm64_armv8-a_shared/libaudioutils.so.abidiff $DIST_DIR/abidiffs/) && exit 1)
******************************************************
error: VNDK library: libaudioutils's ABI has INCOMPATIBLE CHANGES Please check compatibility report at: out/soong/.intermediates/system/media/audio_utils/libaudioutils/android_vendor.31_arm64_armv8-a_shared/libaudioutils.so.abidiff
******************************************************
error: Please update ABI references with: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libaudioutils
[ 83% 111203/133076] //system/media/audio_utils:libaudioutils header-abi-diff libaudioutils.so.abidiff [arm]
FAILED: out/soong/.intermediates/system/media/audio_utils/libaudioutils/android_vendor.31_arm_armv8-a_shared/libaudioutils.so.abidiff
(prebuilts/clang-tools/linux-x86/bin/header-abi-diff -allow-unreferenced-changes -allow-unreferenced-elf-symbol-changes -lib libaudioutils -arch arm -o out/soong/.intermediates/system/media/audio_utils/libaudioutils/android_vendor.31_arm_armv8-a_shared/libaudioutils.so.abidiff -new out/soong/.intermediates/system/media/audio_utils/libaudioutils/android_vendor.31_arm_armv8-a_shared/libaudioutils.so.lsdump -old prebuilts/abi-dumps/vndk/31/64/arm_armv8-a/source-based/libaudioutils.so.lsdump)|| (echo 'error: Please update ABI references with: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libaudioutils' && (mkdir -p $DIST_DIR/abidiffs && cp out/soong/.intermediates/system/media/audio_utils/libaudioutils/android_vendor.31_arm_armv8-a_shared/libaudioutils.so.abidiff $DIST_DIR/abidiffs/) && exit 1)
******************************************************
error: VNDK library: libaudioutils's ABI has INCOMPATIBLE CHANGES Please check compatibility report at: out/soong/.intermediates/system/media/audio_utils/libaudioutils/android_vendor.31_arm_armv8-a_shared/libaudioutils.so.abidiff
******************************************************
error: Please update ABI references with: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libaudioutils
[ 83% 111304/133076] soong_build docs out/soong/docs/soong_build.html
libRkTeeWeaver want to conditional Compile
libgralloc_priv want to conditional Compile
初看这里的报错,一脸懵逼--,再仔细深入读英文得知在out目录有一份报告,
地址是 out/soong/.intermediates/system/media/audio_utils/libaudioutils/android_vendor.31_arm64_armv8-a_shared/libaudioutils.so.abidiff
进入out目录后,打开文档内容:
lib_name: "libaudioutils"
2 arch: "arm"
3 enum_type_diffs {
4 type_stack: "android::audio_utils::Balance::setBalance-> android::audio_utils::Balance *-> android::audio_utils::Balance-> audio_channel_mask_t-> "
5 name: "audio_channel_mask_t"
6 fields_diff {
7 old_field {
8 enum_field_value: 7864316
9 name: "AUDIO_CHANNEL_IN_ALL"
10 }
11 new_field {
12 enum_field_value: 7864318
13 name: "AUDIO_CHANNEL_IN_ALL"
14 }
15 }
16 fields_added {
17 enum_field_value: 262152
18 name: "AUDIO_CHANNEL_IN_08"
19 }
20 fields_added {
21 enum_field_value: 262162
22 name: "AUDIO_CHANNEL_IN_12"
23 }
24 fields_added {
25 enum_field_value: 262176
26 name: "AUDIO_CHANNEL_IN_16"
27 }
28 }
29 compatibility_status: INCOMPATIBLE
AUDIO_CHANNEL_IN_ALL的值确实不一样,再就是后面我新增的三个音频通道的定义,看到这里其实也没有什么解决思路。。。
后来再仔细阅读报错信息,其实这里有说明如何解决:
error: Please update ABI references with: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l libaudioutils
就是执行一个python脚本,于是回到源码的主目录执行脚本,接着又继续报错
看着是脚本要在out目录创建文件夹,但是我没有权限,后续跟公司SCM沟通,取得root权限后继续执行python脚本,仍然报错!
这有又是什么鬼....问题困扰了我大概1天时间,各种尝试,后来也是网上搜到前辈们的文章,说是还要在执行脚本的后面增加 product参数,也即是-product product_name ,增加该参数后继续执行脚本,以为会编译成功呢,一直没关注终端,半个多小时后,又继续编译报错。。。
错误二:
[ 49% 5177/10550] //packages/modules/Permission/PermissionController:PermissionController aapt2 link [common apex30]
packages/modules/Permission/PermissionController/res/layout-television/preference_permissions_category.xml:35: warn: generated id 'android:id/summary' for external package 'android'.
packages/modules/Permission/PermissionController/res/layout-television/preference_permissions_category.xml:27: warn: generated id 'android:id/title' for external package 'android'.
[ 50% 5361/10550] //frameworks/base/packages/SystemUI:SystemUI-core aapt2 link [common]
warn: removing resource com.android.systemui:string/car_add_user without required default value.
warn: removing resource com.android.systemui:string/car_guest without required default value.
warn: removing resource com.android.systemui:string/car_new_user without required default value.
warn: removing resource com.android.systemui:string/start_guest_session without required default value.
warn: removing resource com.android.systemui:string/user_add_user_message_setup without required default value.
warn: removing resource com.android.systemui:string/user_add_user_message_update without required default value.
[ 56% 5907/10471] //packages/apps/TV:LiveTv aapt2 link [common]
warn: removing resource com.android.tv:string/setup_sources_description without required default value.
[ 60% 6146/10211] //frameworks/base:api-stubs-docs-non-updatable check current API [common]
FAILED: out/soong/.intermediates/frameworks/base/api-stubs-docs-non-updatable/android_common/metalava/check_current_api.timestamp
( true && diff -u -F '{ *$' frameworks/base/core/api/current.txt out/soong/.intermediates/frameworks/base/api-stubs-docs-non-updatable/android_common/metalava/api-stubs-docs-non-updatable_api.txt && diff -u -F '{ *$' frameworks/base/core/api/removed.txt out/soong/.intermediates/frameworks/base/api-stubs-docs-non-updatable/android_common/metalava/api-stubs-docs-non-updatable_removed.txt && touch out/soong/.intermediates/frameworks/base/api-stubs-docs-non-updatable/android_common/metalava/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n m api-stubs-docs-non-updatable-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 ) # hash of input list: 029245c8d5b1fb42417b35080e5be16671c76fca0c74c985b4a579247f7b7b1e
--- frameworks/base/core/api/current.txt 2022-05-27 12:41:29.773770347 +0800
+++ out/soong/.intermediates/frameworks/base/api-stubs-docs-non-updatable/android_common/metalava/api-stubs-docs-non-updatable_api.txt 2022-05-27 12:49:10.344732414 +0800
@@ -20436,9 +20436,9 @@ public final class AudioFormat implement
field @Deprecated public static final int CHANNEL_CONFIGURATION_MONO = 2; // 0x2
field @Deprecated public static final int CHANNEL_CONFIGURATION_STEREO = 3; // 0x3
field public static final int CHANNEL_INVALID = 0; // 0x0
- field public static final int CHANNEL_IN_08 = 262152; // 0x40008 add by pzxu for DTEN ON mic start
+ field public static final int CHANNEL_IN_08 = 262152; // 0x40008
field public static final int CHANNEL_IN_12 = 262162; // 0x40012
- field public static final int CHANNEL_IN_16 = 262176; // 0x40020 add by pzxu for DTEN ON mic end
+ field public static final int CHANNEL_IN_16 = 262176; // 0x40020
field public static final int CHANNEL_IN_BACK = 32; // 0x20
field public static final int CHANNEL_IN_BACK_PROCESSED = 512; // 0x200
field public static final int CHANNEL_IN_DEFAULT = 1; // 0x1
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
m api-stubs-docs-non-updatable-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
12:50:19 ninja failed with: exit status 1
#### failed to build some targets (08:48 (mm:ss)) ####
这种编译错误,其实有些似曾相识,在Android 低版本时 新增API后也遇到过类似的错误,主要是在android 的framework层增加了API后,要更新 frameworks/base/core/api/current.txt 的文档,是通过 make update-api 命令执行的更新,命令执行后文档里会生成一句新增接口的标识常量
但是仔细看这里提示的是 m api-stubs-docs-non-updatable-update-current-api
不同版本略微有不同,不过实际还是一样的,经过尝试,有效的执行命令是:
make api-stubs-docs-non-updatable-update-current-api
另外还补充一句,执行该脚本时也需要out目录的root权限,由于公司编译架构的限制,开始执行该脚本时,也会报权限不允许,后来是跟SCM沟通开放root权限后,才得以执行成功,至此整个软件版本也编译通过
参考:
(6条消息) You have tried to change the API from what has been previously approved_平仄散人的博客-CSDN博客
(6条消息) Android P VNDK报错_他叫小黑的博客-CSDN博客_create_reference_dumps.py