首页 > 其他 > 详细

Gson 防止被混淆

时间:2017-01-17 20:07:10      阅读:171      评论:0      收藏:0      [点我收藏+]
##---------------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.google.gson.examples.android.model.** { *; }

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


这是google官方的proguard的文档,请注意倒数第二行,class 后方到**签名的 这一段包名应该是你所有的java bean 定义的目录(在写代码时,应该把java  bean 单独放在一个包中)。

另外附上,
1.Serializable 的配置

# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn‘t save them.
-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();
}

-keep public class * implements java.io.Serializable {*;}
2.可以在proguard中 强制使所有混淆失效
-dontobfuscate
-dontoptimize
转载:http://blog.sina.com.cn/s/blog_4e1e357d0101ednf.html

Gson 防止被混淆

原文:http://www.cnblogs.com/shiyeguiji/p/6294193.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!