• Android之混淆心得与亲身体验


    project.properties 中设置

    proguard.config=proguard-project.txt
    

      

    proguard-project.txt  中设置

    -optimizationpasses 5                           ->设置混淆的压缩比率 0 ~ 7 
    -dontusemixedcaseclassnames                     -> Aa aA 
    -dontskipnonpubliclibraryclasses                ->如果应用程序引入的有jar包,并且想混淆jar包里面的class 
    -dontpreverify        
    -verbose                                        ->混淆后生产映射文件 map 类名->转化后类名的映射
    -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*       ->混淆采用的算法.
    
    -keep public class * extends android.app.Activity                         ->所有activity的子类不要去混淆
    -keep public class * extends android.app.Application
    -keep public class * extends android.app.Service
    -keep public class * extends android.content.BroadcastReceiver
    -keep public class * extends android.content.ContentProvider
    -keep public class * extends android.app.backup.BackupAgentHelper
    -keep public class * extends android.preference.Preference
    -keep public class com.android.vending.licensing.ILicensingService
    
    -dontwarn android.support.v4.**
    -dontwarn android.annotation
    
    
    -libraryjars libs/android-support-v4.jar
    
    
    -keepclasseswithmembernames class * {            -> 所有native的方法不能去混淆. 
        native <methods>;
    }
    
    -keepclasseswithmembers class * {
        public <init>(android.content.Context, android.util.AttributeSet);            -->某些构造方法不能去混淆
    }
    
    -keepclasseswithmembers class * {
        public <init>(android.content.Context, android.util.AttributeSet, int);
    }
    
    -keepclassmembers class * extends android.app.Activity {
       public void *(android.view.View);
    }
    -keepclassmembers enum * {                                -> 枚举类不能去混淆
        public static **[] values();
        public static ** valueOf(java.lang.String);
    }
    
    -keep class * implements android.os.Parcelable {              -> aidl文件不能去混淆. 
      public static final android.os.Parcelable$Creator *;
    }
    
    -keepclassmembers class * {
       public <init>(org.json.JSONObject);
    }
    
    -keep class android.support.v4.**{*;}
    -keepattributes *Annotation*
    
    ============================================
    对于引用第三方包的情况,可以采用下面方式避免打包出错:
    -libraryjars libs/aaa.jar
    -dontwarn com.xx.yy.**
    -keep class com.xx.yy.** { *;}
  • 相关阅读:
    说谎的简单工厂模式设计模式&amp;工厂方法模式&amp;Abstract Factory模式
    [Gevent]gevent 网络抓取问答
    使用 Capistrano 和写作 Ruby 迭代边缘部署
    【从翻译mos文章】在oracle db 11gR2版本号被启用 Oracle NUMA 支持
    [Unity3D]Unity3D圣骑士模仿游戏开发传仙灵达到当局岛
    [RxJS] Logging a Stream with do()
    [RxJS] Handling a Complete Stream with Reduce
    [RxJS] Completing a Stream with TakeWhile
    [RxJS] Adding Conditional Logic with Filter
    [RxJS] Combining Streams with CombineLatest
  • 原文地址:https://www.cnblogs.com/lee0oo0/p/3457877.html
Copyright © 2020-2023  润新知