Android的Proguard的重复定义定义、Android、Proguard

2023-09-12 10:32:06 作者:深情从来都被辜负

我尝试添加第三方库(JmDNS)我的Andr​​oid项目。

I'm attempting to add a 3rd party library (JmDNS) to my Android project.

我创建的基本项目目录下的文件夹库,并在该目录下降jar文件。

I created a folder 'libs' under the base project directory, and dropped the jar file in the directory.

当我试图建立自己项目使用Ant(蚂蚁释放),我收到一个重复定义的通知似乎是每个类的JmDNS jar文件。

When I attempt to build he project using Ant (ant release), I receive a 'duplicate definition' notices for what appears to be each class in the JmDNS jar file.

....
[proguard] Note: duplicate definition of library class [javax.jmdns.impl.tasks.state.Canceler]
[proguard] Note: duplicate definition of library class [javax.jmdns.impl.tasks.state.DNSStateTask]
[proguard] Note: duplicate definition of library class [javax.jmdns.impl.tasks.state.Prober]
[proguard] Note: duplicate definition of library class [javax.jmdns.impl.tasks.state.Renewer]
[proguard] Note: duplicate definition of library class [javax.jmdns.impl.tasks.state.package-info]
[proguard] Note: duplicate definition of library class [javax.jmdns.package-info]
[proguard] Note: there were 357 duplicate class definitions.

构建也失败,出现以下错误:

The build also fails with the following error:

BUILD FAILED
/path/Tools/ant-android-scala/build-scala.xml:183: Can't write [/path/bin/projectname-debug-shrinked.jar] (Can't read [/path/projectname/libs/jmdns.jar(;;;;!META-INF/MANIFEST.MF,!library.properties)] (Duplicate zip entry [jmdns.jar:javax/jmdns/JmDNS$Delegate.class]))

我做了肯定的jar文件仅包含一次,并且存在我包括重复的源文件中的任何地方项目没有其他办法。

I've made sure that the jar file is only included once, and there is no other way that I am including duplicate source files anywhere in the project.

否则为什么ProGuard的抱怨重复定义?

Why else would Proguard complain about duplicate definitions?

推荐答案

通过将第三方库到另一个目录中,在我的情况下,'库'解决了这个。然后添加

Fixed this by moving the 3rd party libraries to another directory, in my case 'lib'. Then added

-injars lib/jmdns.jar 

到proguard.cfg文件。

to the proguard.cfg file.

如果第三方磅都包含在库的文件夹,则它们被处理两次。

If the 3rd party lbs are included in the 'libs' folder, then they are processed twice.