资讯详情

Android S内置APK时AndroidManifest使用uses-library编译报错

Google关于这方面Android S文档输出可参考以下变更:Dexpreopt 和 uses-library 检查。

本报错主要是构建系统Android.bp或Android.mk文件中的信息和Manifest建立清单时,应检查清单之间的一致性,并要求声明请求的使用情况libraries跟AndroidManifest.xml声明的一致性,否则会报错。

接下来检查编译报错:

error: mismatch in the <uses-library> tags between the build system and the manifest:     - required libraries in build system: []                      vs. in the manifest: [org.apache.http.legacy]     - optional libraries in build system: []                      vs. in the manifest: [com.x.y.z]     - tags in the manifest (.../X_intermediates/manifest/AndroidManifest.xml):         <uses-library android:name="com.x.y.z"/>         <uses-library android:name="org.apache.http.legacy"/>  note: the following options are available:     - to temporarily disable the check on command line, rebuild with RELAX_USES_LIBRARY_CHECK=true (this will set compiler filter "verify" and disable AOT-compilation in dexpreopt)     - to temporarily disable the check for the whole product, set PRODUCT_BROKEN_VERIFY_USES_LIBRARIES := true in the product makefiles     - to fix the check, make build system properties coherent with the manifest     - see build/make/Changes.md for details 

可根据提示进行以下三种尝试修改:

:在MK当中配置PRODUCT_BROKEN_VERIFY_USES_LIBRARIES := true;

该项目在构建过程中仍将进行一致性检查,但检查失败并不意味着构建失败。相反,检查失败会降级构建系统 dex2oat 编译器过滤器 dexpreopt 中进行verify ,从而完全禁用该模块 AOT 编译。

:请使用环境变量RELAX_USES_LIBRARY_CHECK=true;

它与PRODUCT_BROKEN_VERIFY_USES_LIBRARIES它有相同的效果,但目的是命令。环境变量覆盖产品变量。

:请让构建系统了解清单中的标记;

检查Androidanifest.xml或APK内的清单,可以使用aapt dump badging $APK | grep uses-library来检查,然后在MK文件中进行如下配置:

//LOCAL_USES_LIBRARIES := <library-module-name>
//LOCAL_OPTIONAL_USES_LIBRARIES := <library-module-name>

LOCAL_OPTIONAL_USES_LIBRARIES := org.apache.http.legacy    androidx.window.extensions     androidx.window.sidecar

//Android.bp

enforce_uses_libs: false,
dex_preopt: { 
       
    enabled: false,
},

//Android.mk

LOCAL_ENFORCE_USES_LIBRARIES := false
LOCAL_DEX_PREOPT := false

标签: 集成电路mk41s80x

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台