使用Proguard时出现META-INF/版本重复错误 [英] META-INF/version duplicate error when using Proguard

查看:2553
本文介绍了使用Proguard时出现META-INF/版本重复错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

等级:4.10.1 Gradle Android插件版本:3.3.2 Proguard:6.0.3 JDK-1.9 Android Studio 3.3.2 当我尝试与Proguard一起构建apk发行版时.我收到以下错误-

Gradle : 4.10.1 Gradle Android Plugin version : 3.3.2 Proguard : 6.0.3 JDK - 1.9 Android Studio 3.3.2 When I try to build apk release version along with Proguard. I get the following error -

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)
    ......

这似乎是由于此引起的-

This seems to be caused due to this -

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似乎有问题.我有多个包含此的依赖项.

From extensive searching it looks like Proguard has a problem with META-INF/versions/9. I have multiple dependencies that contain this.

虽然似乎已对该问题进行了记录,但没有规定的解决方案似乎奏效. https://sourceforge.net/p/proguard/bugs/665/ 建议通过-

While the issue to seems to somewhat documented, no solutions prescribed seem to work. https://sourceforge.net/p/proguard/bugs/665/ suggests filtering out those class files via -

-injars my_lib.jar(!META-INF/versions/**.class)

但是,当我尝试此操作时,它只是将更多文件标记为重复文件并命名错误.我还尝试通过gradle排除它-

However when I try this it just labels more files as duplicate and incorrectly named. I also tried excluding it via 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'
   }

这也无法解决问题.我该如何解决这个问题?

This also fails to resolve the problem. How do I solve this problem ?

推荐答案

我意识到这是一个非常老的问题,但是我可以使用以下gradle配置使它起作用:

I realise this is a very old question, but I was able to get this to work using this gradle configuration:

task obfuscate(type: proguard.gradle.ProGuardTask) {
    configuration files("proguard-project.txt")
    libraryjars files("build/rt.jar", "build/jce.jar")
    injars files("build/libs/desktop-${version}.jar"), filter: "!META-INF/versions/**/*.class"
    outjars files("build/libs/obfuscated.jar")
}

我认为您使用的injars指令的问题可能是路径-应该为META-INF/versions/**/*.class.

I think the issue with the injars directive you used might be the path - should be META-INF/versions/**/*.class.

这篇关于使用Proguard时出现META-INF/版本重复错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆