我有简单的 POJO,每个属性都有 getter 和 setter。除了那些名为 id 和 serialNumber 的东西外,所有东西都被混淆了。
id 属性不会被重命名,它的 getter 和 setter 也不会。
serialNumber 属性确实被重命名,但它的 getter 和 setter 没有。
这些属性没有什么特别之处,我也没有在我的 Proguard 配置中添加任何东西来让 Proguard 以不同的方式对待它们。
我的 Proguard 配置
# Fudge around some issues
-dontskipnonpubliclibraryclasses
# Preserve all annotations.
-keepattributes *Annotation*
# Preserve all native method names and the names of their classes.
-keepclasseswithmembernames class * {
native <methods>;
}
# Preserve the special static methods that are required in all enumeration
# classes.
-keepclassmembers class * extends java.lang.Enum {
public static **[] values();
public static ** valueOf(java.lang.String);
}
# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
# You can comment this out if your application doesn't use serialization.
# If your code contains serializable classes that have to be backward
# compatible, please refer to the manual.
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
# Keep some source file attributes so we have a chance of decoding stack traces
-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
# make sure we keep info for downstream libraries
-dontshrink
-dontoptimize
-useuniqueclassmembernames
以及地图文件的输出
java.lang.String id -> id
int productCode -> a
int platform -> b
java.lang.String model -> c
java.lang.String serialNumber -> d
java.lang.String machineID -> e
java.lang.String parentSerialNumber -> f
long clientTime -> g
38:38:java.lang.String getId() -> getId
47:48:void setId(java.lang.String) -> setId
52:52:int getProductCode() -> a
57:58:void setProductCode(int) -> a
62:62:int getPlatform() -> b
67:68:void setPlatform(int) -> b
72:72:java.lang.String getModel() -> c
77:78:void setModel(java.lang.String) -> a
82:82:java.lang.String getSerialNumber() -> getSerialNumber
87:88:void setSerialNumber(java.lang.String) -> setSerialNumber
92:92:java.lang.String getMachineID() -> d
97:98:void setMachineID(java.lang.String) -> b
102:102:java.lang.String getParentSerialNumber() -> e
107:108:void setParentSerialNumber(java.lang.String) -> c
112:112:long getClientTime() -> f
117:118:void setClientTime(long) -> a