zoukankan      html  css  js  c++  java
  • 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.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
  • 相关阅读:
    NOI 2020 游记
    BJOI2020 游记
    行列式
    CSP-S 2019 游记
    类欧几里得算法
    有关二次离线和 Yuno loves sqrt technology II
    NOI2019 游记
    CTS 2019 Pearl
    BJOI2019 游记
    2017 山东二轮集训 Day7 国王
  • 原文地址:https://www.cnblogs.com/shiyeguiji/p/6294193.html
Copyright © 2011-2022 走看看