安卓编译 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]
``
发布了116 篇原创文章 · 获赞 73 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/weixin_42514606/article/details/104356952