Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

I do not see a way to remove the duplicates from the used libraries. Even after using dontwarn the warnings do not vanish.

Is this the right way of handling this warning in just ignoring it or could this lead to problems?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
466 views
Welcome To Ask or Share your Answers For Others

1 Answer

If you add a proguard option -printconfiguration config.txt you'll see proguard adds

-libraryjars 'D:oolsandroidplatformsandroid-23android.jar'

-libraryjars 'D:oolsandroidplatformsandroid-23optionalorg.apache.http.legacy.jar'

your duplicated classes (e.g. SslError) are presented in both android.jar and org.apache.http.legacy.jar

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...