Reputation: 793
Reading proguard rules
I found my self facing three terms that seemed to be very similar
keep
keepclassmembers
keepclasswithmembers
I couldn't understand the difference between those three rules, Can someone explain the difference a bit better and maybe an example as well
Upvotes: 21
Views: 11561
Reputation:
1) keep - preserve classes
2) keepclassmembers - preserve class members such as fields & methods
3) keepclasseswithmembers - preserve classes if they satisfy certain conditions based on members
Examples
1) preserve all classes extending android.app.Activity
-keep public class * extends android.app.Activity
2) preserve all member ( static field ) named CREATOR on the condition if they are implementing android.os.Parcelable
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
3) preserve all classes if they have constructor ( mentioned below as init ) with parameters( Context, AttributeSet ) or ( Context, AttributeSet , int ) .
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
Upvotes: 33