0

The app has dependency on library, which has class members with

@SuppressWarnings("unused")

annotation. When I made use of proguard-rules.pro by,

minifyEnabled true

in gradle file, the members with above annotations are not found at runtime, with

NoSuchFieldError error. 

How to keep those members from that library package, with annotation

@SuppressWarnings("unused")

, through

"proguard-rules.pro" 
Annada
  • 1,075
  • 1
  • 18
  • 21

2 Answers2

2

The @SuppressWarnings annotation has source-level retention, thus it is not present in the actual class file that is processed by ProGuard.

You will have to add specific ProGuard rules yourself to keep these fields if you need them at runtime.

To keep all fields of a class you can use a rule like this:

-keep class xxx.yyy {
    <fields>;
}
T. Neidhart
  • 6,060
  • 2
  • 15
  • 38
0

try using something like this for the specific class you are using:

-dontwarn {package name}.{class name}
-keep class {package name}.{class name} { *; }
-keep interface {package name}.{class name} { *; }
masoud vali
  • 1,528
  • 2
  • 18
  • 29
  • Thanks for your suggestion. Actually I want to keep those class members which are annotated with @SuppressWarnings("unused"). Anyway other methods are not removed by obfuscation. 1. Keep methods which are annotated with @SuppressWarnings("unused") 2. Also Obfuscate those methods in point-1 – Annada Nov 24 '16 at 14:50