美文网首页
android混淆

android混淆

作者: 黎院根 | 来源:发表于2021-04-13 14:30 被阅读0次
    # 压缩质量  0~7
    -optimizationpasses 5
    
    #不采用大小写命名的混淆
    -dontusemixedcaseclassnames
    
    #不跳过类库例的非公共类
    -dontskipnonpubliclibraryclasses
    
    #混淆时是否记录日志(混淆后生产映射文件 map 类名 -> 转化后类名的映射
    -verbose
    
    #不跳过类库中的非公共方法
    -dontskipnonpubliclibraryclassmembers
    
    # 不做预校验
    -dontpreverify
    
    # 不混淆注解和内部类
    -keepattributes *Annotation*,InnerClasses
    
    #保持泛型
    -keepattributes Signature
    
    #保持源文件以及行号
    -keepattributes SourceFile,LineNumberTable
    
    # 混淆算法
    -optimizations !code/simplification/cast,!field/*,!class/merging/*
    
    
    #############################################
    #
    # Android开发中一些需要保留的公共部分
    #
    #############################################
    
     ## 注册等需要类名,所以不能被混淆
    -keep public class * extends android.app.Activity
    -keep public class * extends android.app.Appliction
    -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 * extends android.view.View
    -keep public class com.android.vending.licensing.ILicensingService
    
    -keep class **.R$* {*;}
    
    -keepclasseswithmembernames class * {
        native <methods>;
    }
    -keepclassmembers class * extends android.app.Activity{
        public void *(android.view.View);
    }
    -keepclassmembers enum * {
        public static **[] values();
        public static ** valueOf(java.lang.String);
    }
    -keep public class * extends android.view.View{
        *** get*();
        void set*(***);
        public <init>(android.content.Context);
        public <init>(android.content.Context, android.util.AttributeSet);
        public <init>(android.content.Context, android.util.AttributeSet, int);
    }
    
    # 序列化
    -keep class * implements android.os.Parcelable {
      public static final android.os.Parcelable$Creator *;
    }
    
    # 同上
    -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();
    }
    
    #触摸事件
    -keepclassmembers class * {
        void *(**On*Event);
    }
    

    相关文章

      网友评论

          本文标题:android混淆

          本文链接:https://www.haomeiwen.com/subject/tdfclltx.html