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

(1)安装或编译出现的错误

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

根据提示可以做如下三种尝试修改:

(A)产品范围的临时修复:在MK当中配置PRODUCT_BROKEN_VERIFY_USES_LIBRARIES := true;

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

(B)快速进行全局命令行修复:请使用环境变量RELAX_USES_LIBRARY_CHECK=true;

它与PRODUCT_BROKEN_VERIFY_USES_LIBRARIES具有相同的效果,但旨在用于命令行。环境变量覆盖产品变量。

(C)根本原因修复:请让构建系统了解清单中的标记;

检查AndroidManifest.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

(2)一劳永逸之法

//Android.bp

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

//Android.mk

LOCAL_ENFORCE_USES_LIBRARIES := false
LOCAL_DEX_PREOPT := false


---------------------
作者:雪舞飞影
来源:CSDN
原文:https://blog.csdn.net/dongxianfei/article/details/123665498
版权声明:本文为作者原创文章,转载请附上博文链接!
内容解析By:CSDN,CNBLOG博客文章一键转载插件

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值