我有簡單的POJO,每個屬性都有getter和setter。除了那些名爲id和serialNumber之外,所有的都被模糊處理。Proguard沒有模糊方法getId()和getSerialNumber()
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