之前一直忙於項目,好長時間沒有更新內容了
在項目打包的時候,遇到了些問題,在此記錄一些吧
在項目中引用了Google提供的開源項目Gson來解析json,在代碼混淆之後出現了些問題,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
# 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.google.gson.<span style="color:#FF0000;">examples.android.model.** { *; }</span>
-keep class <span style="color:#FF0000;">examples.android.model.** { *; }</span>
##---------------End: proguard configuration for Gson ----------
把紅色區域改爲自己model的路徑