ProGuard:库类的重复定义? [英] ProGuard: duplicate definition of library class?
问题描述
我为我的Android项目运行ProGuard并收到以下警告:
I run my ProGuard for my Android project and get the following warnings:
Note: duplicate definition of library class [org.apache.http.conn.scheme.HostNameResolver]
Note: duplicate definition of library class [org.apache.http.conn.scheme.SocketFactory]
Note: duplicate definition of library class [org.apache.http.conn.ConnectTimeoutException]
Note: duplicate definition of library class [org.apache.http.params.HttpParams]
Note: duplicate definition of library class [android.net.http.SslCertificate$DName]
Note: duplicate definition of library class [android.net.http.SslError]
Note: duplicate definition of library class [android.net.http.SslCertificate]
Note: there were 7 duplicate class definitions.
我发现这里通过忽略它来解决这个问题:
I found here to fix this with ignoring it with:
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
-keep class android.net.http.** { *; }
-dontwarn android.net.http.**
我看不出办法从已使用的库中删除重复项。即使在使用 dontwarn
之后,警告也不会消失。
I do not see a way to remove the duplicates from the used libraries. Even after using dontwarn
the warnings do not vanish.
这是处理此警告的正确方法吗只是忽略它或者这会导致问题吗?
推荐答案
如果你添加一个proguard选项 -printconfiguration config.txt
你会看到proguard添加
If you add a proguard option -printconfiguration config.txt
you'll see proguard adds
-libraryjars'D:\tools \ android\platforms\android-23 \ android.jar'
-libraryjars 'D:\tools\android\platforms\android-23\android.jar'
-libraryjars'D:\tools \ android \platforms\android- 23 \optional\org.apache.http.legacy.jar'
-libraryjars 'D:\tools\android\platforms\android-23\optional\org.apache.http.legacy.jar'
你的重复类(例如SslError)都出现在两者中android.jar和org.apache.http.legacy.jar
your duplicated classes (e.g. SslError) are presented in both android.jar and org.apache.http.legacy.jar
即使你没有 useLibrary'org.apache,Proguard也会添加第二个jar。 http.legacy'
这是打开错误描述问题。
Proguard adds second jar even if you don't useLibrary 'org.apache.http.legacy'
Here is an open bug describing the problem.
所以现在我们无法解决这个问题。只需忽略它:
So now we can't do anything with the issue. Just ignore it:
-dontnote android.net.http.*
-dontnote org.apache.commons.codec.**
-dontnote org.apache.http.**
没有必要只要它们位于库jar(实际上是电话库)中,就保留这些类。
dontwarn不起作用,因为它不是警告,它是一张便条。
There is no need to keep the classes as long as they are located in library jar (phone's library actually). dontwarn doesn't work because it's not a warning, it's a note.
这篇关于ProGuard:库类的重复定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!