android 混淆打包后 Gson拿到的实体类转换异常

配置gson混淆(复制下面这段到混淆文件):
##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.xxx.entity.** { *; }

##---------------End: proguard configuration for Gson  ----------

注意:上面倒数第二行是防止你的实体类被混淆, com.xxx.entity. 是你实体类的包路径

你可能感兴趣的:(Android)