Android上的Proguard和JMDNS问题



故事是这样的:我需要为Android库配置Proguard,它包含一个带有JMDNS库的.jar文件。我知道代码运行得很好。

当我启用proward并尝试构建库时,在控制台上打印以下错误

Warning:javax.jmdns.impl.DNSCache: can't find referenced method 'java.util.concurrent.ConcurrentHashMap$KeySetView keySet()' in program class javax.jmdns.impl.DNSCache
Warning:javax.jmdns.impl.DNSCache: can't find referenced class java.util.concurrent.ConcurrentHashMap$KeySetView
Warning:there were 2 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning:there were 1 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile the code.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)

阅读了一点,我发现标记-dontwarn可以用来忽略这种类型的警告。应用它之后,控制台显示以下警告

Warning:javax.jmdns.impl.DNSCache: can't find referenced method 'java.util.concurrent.ConcurrentHashMap$KeySetView keySet()' in program class javax.jmdns.impl.DNSCache
Warning:there were 1 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile the code.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)

是否有办法消除该消息,以便编译过程可以继续?我试图用失败的方法添加另一个-dontwarn,甚至没有成功的标签-ignorewarnings

顺便说一下,我的proguard-rules.pro:
-keep class com.google.common.io.Resources {
    public static <methods>;
}
-keep class com.google.common.collect.Lists {
    public static ** reverse(**);
}
-keep class com.google.common.base.Charsets {
    public static <fields>;
}
-keep class com.google.common.base.Joiner {
    public static Joiner on(String);
    public ** join(...);
}
-keep class com.google.common.collect.MapMakerInternalMap$ReferenceEntry
-keep class com.google.common.cache.LocalCache$ReferenceEntry
-keep class java.util.concurrent.ConcurrentHashMap$KeySetView
-dontwarn sun.misc.Unsafe
-dontwarn java.util.concurrent.ConcurrentHashMap$KeySetView

Thanks in advance

我自己解决了这个问题,并将回答我自己的问题,以便解决方案可以帮助别人

这个警告基本上指出了解决方案:

Your input classes appear to be inconsistent.
You may need to recompile the code.

起初我以为是我的代码需要重新编译,但相反,是JMDNS代码有问题。下载源代码自己编译后,问题没有出现

相关内容

  • 没有找到相关文章

最新更新