代码混淆 GSON完满解决

xiaoxiao2021-02-28  84

头疼的问题,json使用了google的gson三方包,可是混淆的时候出了问题

明明已经按照gson的官方文档,把混淆脚本加上去了,却还是出问题。

今天同事找到一篇博客,关于这个问题的:

我们是将json解析以后放到javabean中去的,但是一直出问题,放进去的字符串是对的,解析出来的javabean却是空,节操碎一地

-keep class com.google.**{*;} -keepclassmembers class * implements java.io.Serializable {     static final long serialVersionUID;     private 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(); } ##---------------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.examples.android.model.** { *; }  ##这里需要改成解析到哪个  javabean ##---------------End: proguard configuration for Gson  ----------

这些个是官方给的脚本,放进去那叫一蛋疼,坑爹

最后一篇博客9了我:http://blog.sina.com.cn/s/blog_4e1e357d0101ednf.html

大致是 倒数第二行 需要让所有定义的javabean不被混淆,改过来之后就好了,十分感谢,希望朋友们也少走弯路

英文不好也是相当的坑爹呀,唉

转自:http://www.cnblogs.com/dyllove98/archive/2013/07/25/3215037.html

转载请注明原文地址: https://www.6miu.com/read-56298.html

最新回复(0)