安卓编译 instances of library classes depending on program classes
问题
执行命令:
/bin/bash -c "external/proguard/bin/proguard.sh -injars 'out/target/common/obj/APPS/TileLauncher_intermediates/classes-desugar.jar' -outjars out/target/common/obj/APPS/TileLauncher_intermediates/classes-proguard.jar -libraryjars out/target/common/obj/APPS/TileLauncher_intermediates/proguard_dictionary -forceprocessing -include build/core/proguard.flags -dontobfuscate -dontoptimize -include out/target/common/obj/APPS/TileLauncher_intermediates/proguard_options"
错误的结果
ProGuard, version 5.1
Reading library jar [ out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar]
Reading library jar [ out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/classes.jar]
Reading library jar [ out/target/common/obj/JAVA_LIBRARIES/core-lambda-stubs_intermediates/classes.jar]
Warning: library class android.hardware.cas.V1_0.ICas extends or implements program class android.hidl.base.V1_0.IBase
Warning: library class android.hardware.cas.V1_0.ICasListener extends or implements program class android.hidl.base.V1_0.IBase
Warning: there were 16 instances of library classes depending on program classes.
You must avoid such dependencies, since the program classes will
be processed, while the library classes will remain unchanged.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dependency)
Error: Please correct the above warnings first.
解决方法
根据关键字找到官网的建议方法。
https://www.guardsquare.com/en/products/proguard/manual/troubleshooting#dependency
If you don’t feel like filtering out the problematic classes, you can try your luck with the
-ignorewarnings
option, or even the-dontwarn
option. Only use these options if you really know what you’re doing though.
只需要在ProGuard
规则文件build/core/proguard.flags
末尾加上过滤信息即可
。
在文件上修改,即可。重新执行。
-dontwarn android.hidl.base.**
-keep class android.hidl.base.**
修改后的结果,没有错误
ProGuard, version 5.1
Reading program jar [out/target/common/obj/APPS/TileLauncher_intermediates/classes-desugar.jar]
Copying resources from program jar [out/target/common/obj/APPS/TileLauncher_intermediates/classes-desugar.jar]
``
作者:叉叉敌
博客:https://chasays.github.io/
微信公众号:Chasays, 欢迎关注一起吹牛逼,也可以加个人微信号「xxd_0225」互吹。
本博客大多为学习笔记或读书笔记,本文如对您有帮助,还请多推荐下此文,如有错误欢迎指正,相互学习,共同进步。