简体   繁体   中英

Proguard: can't find referenced method 'void addSuppressed(java.lang.Throwable)' in library class java.lang.Throwable

When running ProGuard I get the following warning:

can't find referenced method 'void addSuppressed(java.lang.Throwable)' in library class java.lang.Throwable

Here is my proguard rule:

-injars build/libs/test-main-1.0.jar
-libraryjars /System/Library/Frameworks/JavaVM.framework/Classes/classes.jar

-dontoptimize
-dontobfuscate
-dontpreverify
-printusage
-dontnote

-keep public class com.foo.app.Main {
    public static void main(java.lang.String[]);
}

-keepclassmembers class * {
    static final % *;
    static final java.lang.String *;
}

Edit: I use proguard from the command line with the proguard.jar.

How do I prevent this Warning? Isn't Throwable part of classes.jar ?

The addSuppressed method, used in try with resources syntax, is not supported in Android. Don't use that syntax and you'll be fine.

I solved this problem by changing my SDK version 18 to 19 in the file named build.gradle :

the old:

compileSdkVersion 18

now is:

compileSdkVersion 19

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM