javaandroidproguardjmdns

Proguard and JMDNS issue on Android


This is the story: I need to configure Proguard for an Android library, which contains a .jar file with JMDNS library. I know that the code works perfectly.

When I enable proward, and try build the library, The following errors where printed on the console

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)

Reading a bit, I found out that the tag -dontwarn can be used to ignore this type of warnings. After apply it, the console shows this warning

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)

Is there a way to get rid of that message, so the compilation process can continue? I've tried to add another -dontwarn with the failing method, and even the tag -ignorewarnings with no success.

By the way, my 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


Solution

  • I solved it myself, and will answer my own question so the solution can help others

    The warning basically point out the solution:

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

    At first I thought that was my code that need to be recompiled, but instead,was the JMDNS code who was faulty. After downloading the source code and compiling myself, the issue did not appear