Gradle:4.10.1 Gradle Android 插件版本:3.3.2 Proguard:6.0.3 JDK - 1.9 Android Studio 3.3.2 当我尝试与 Proguard 一起构建 apk 发布版本时。我收到以下错误 -
Caused by: java.io.IOException: Please correct the above warnings first.
at proguard.InputReader.execute(InputReader.java:149)
at proguard.ProGuard.readInput(ProGuard.java:255)
at proguard.ProGuard.execute(ProGuard.java:96)
......
这似乎是由于这个 -
Warning: class [META-INF/versions/9/module-info.class] unexpectedly contains class [module-info]
Note: duplicate definition of program class [module-info]
Note: there were 20 duplicate class definitions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning: there were 21 classes in incorrectly named files.
You should make sure all file names correspond to their class names.
The directory hierarchies must correspond to the package hierarchies.
从广泛的搜索来看,Proguard 的 META-INF/versions/9 似乎存在问题。我有多个包含此的依赖项。
虽然这个问题似乎有些记录,但似乎没有规定的解决方案有效。 https://sourceforge.net/p/proguard/bugs/665/ 建议通过以下方式过滤掉这些类文件 -
-injars my_lib.jar(!META-INF/versions/**.class)
但是,当我尝试这样做时,它只会将更多文件标记为重复且名称错误。我也尝试通过 gradle 排除它-
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/versions'
exclude 'META-INF/versions/9/module-info.class'
}
这也无法解决问题。我该如何解决这个问题?