Proguard keep classmembers

2019-06-16 03:35发布

How can I tell proguard to keep my classmembers?

I need them for JSON compatibility...

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 already tried, but it doesnt work...

-keepclassmembers class com.tools.app.holiday.Holiday 

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

I also implemented serialisable and did:

-keepclassmembers class * implements java.io.Serializable {

But it all doesn't keep my member names. Proguard always changes ist to a, b, c :-( What am I missing?

1条回答
The star\"
2楼-- · 2019-06-16 04:01

All class names must be fully qualified:

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

By default, ProGuard even prints out messages if you forget this.

查看更多
登录 后发表回答