Question

This is my class:

package com.tools.app.holiday;

public class Holiday {  

    private String name;

    private Calendar dateFrom = Calendar.getInstance();

    private Calendar dateTo = Calendar.getInstance();

    ...

I can keep these private fields by putting the following in my ProGuard rules file:

-keepclassmembers class com.tools.app.holiday.Holiday {
    private java.lang.String name;    
    private java.util.Calendar dateFrom;
    private java.util.Calendar dateTo;
}

But I'd prefer not to have to specify each field individually. How can I do this?

P.S. I stole most of this from Proguard keep classmembers because that question was close to what I'm asking.

Was it helpful?

Solution

According to ProGuard documenation the wildcard <fields> matches any field. Thus it should be something like:

-keepclassmembers class com.tools.app.holiday.Holiday {
    private <fields>;    
}

If you want to preserve private fields in all classes use:

-keepclassmembers class * {
    private <fields>;    
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top