问题:通过Gson解析数据后,获取解析到的对象中的内容,没有任何数据,控制台也没有任何有关异常或错误的输出
如:
Type listType = new TypeToken<ArrayList<OpenEntity>>(){}.getType();
ArrayList<OpenEntity> openUrlEntities= gson.fromJson(mess,listType);
集合长度大于0,但是循环遍历对象中的所有内容都为null
原因:打正式包时对数据进行了混淆
解决方法:
在混淆文件中添加如下代码
#proguard for gson
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.examples.android.model.** { *; }
-keep class xxx.xxx.xxx.model.** {*;}
xxx.xxx.xxx.model为保存对象的类的完整的包名