首页 > 代码库 > 常用的混淆配置

常用的混淆配置

前段时间开发了好多的项目,但是往往都是最后混淆这块费了好大劲的,现在我把这些常用的混淆配置写下来,仅供参考吧!

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontwarn
-dontpreverify
-dontskipnonpubliclibraryclassmembers
-ignorewarnings
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
  
-libraryjars libs/afinal_0.5.1_bin.jar

# mode 混淆
-keep class shzb.zhinaibo.mode.** { *; }

# FastJson 混淆
# 如果是有mode的get和set方法,需要设置下面这条语句
-dontwarn com.alibaba.fastjson.**
-keep class com.alibaba.fastjson.** { *; }
-keepattributes Signature
#-keepattributes *Annotation*

# v4 包的混淆
#-libraryjars ./libs/android-support-v4.jar
#-dontwarn android.support.**
-dontwarn android.support.v4.**
-dontwarn **CompatHoneycomb
-dontwarn **CompatHoneycombMR2
-dontwarn **CompatCreatorHoneycombMR2
-keep interface android.support.v4.app.** { *; }
-keep class android.support.v4.** { *; }
-keep public class * extends android.support.v4.**
-keep public class * extends android.app.Fragment



# slidingmenu 的混淆
-dontwarn com.jeremyfeinstein.slidingmenu.lib.**
-keep class com.jeremyfeinstein.slidingmenu.lib.** { *; }


# ActionBarSherlock混淆
-dontwarn com.actionbarsherlock.**
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }

-keep class * extends java.lang.annotation.Annotation { *; }

# 保持自定义控件类不被混淆
-keep public class * extends com.zhibaicc.android.adapter.PackageAdapter

-keepclasseswithmembers class * {                                              
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * implements android.os.Parcelable {
    static android.os.Parcelable$Creator CREATOR;
}

-keep public class * implements java.io.Serializable {
        public *;
}

# afinal混淆
-dontwarn net.tsz.afinal.**
-keep class net.tsz.afinal.** { *; }
-keep public class * extends net.tsz.afinal.** 
-keep public interface net.tsz.afinal.** {*;}

-keepclasseswithmembers class shzb.zhinaibo.base.** {
     <fields>;
     <methods>;
}

# universal-image-loader 混淆
-dontwarn com.nostra13.universalimageloader.**
-keep class com.nostra13.universalimageloader.** { *; }


# ShareSDK 混淆
-dontwarn cn.sharesdk.**
-keep class cn.sharesdk.** { *; }

常用的混淆配置