这是我的实体类:
class Entity{
private String id;
Object content;
private Type type;
public enum Type{type1, type2, type3}
}
根据type
字段,我将相应的类传递给
gson.fromJson(json, <type1/2/3 class, depending on field type>);
但是我正在使用混淆器,这会混淆类型值,因此我无法确定要使用哪个类。
我尝试保留类型字段,但它没有保留。这是我的代码:
-keepclassmembers enum * { *; }
-keepclassmembers class com.mypkg.Entity {
private java.lang.String id;
private com.mypkg.Entity.Type type;
}
我看到 id 被保留,但类型字段没有保留。
请帮忙。
最佳答案
This thread可能有帮助。
-keep public enum com.mypkg.Entity$** {
**[] $VALUES;
public *;
}
关于android - 如何在 proguard 中保留 Enum 类型字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34998610/