故事是这样的:我需要为一个 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
提前致谢