How to tell ProGuard to keep private fields without specifying each field
Asked Answered
T

1

39

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.

Tymon answered 29/4, 2014 at 12:43 Comment(0)
D
57

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>;    
}
Decree answered 29/4, 2014 at 13:4 Comment(1)
How about -keepclasseswithmembers class * { @com.activeandroid.annotation.Column <fields>; }Myth

© 2022 - 2024 — McMap. All rights reserved.