ProGuard:库类的重复定义? [英] ProGuard: duplicate definition of library class?

查看:30
本文介绍了ProGuard:库类的重复定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的 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.http.legacy',Proguard 也会添加第二个 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.**

只要它们位于库 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屋!

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