Proguard keep classmembers

泄露秘密 提交于 2020-01-03 07:34:06

问题


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:


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.



来源:https://stackoverflow.com/questions/8418733/proguard-keep-classmembers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!