Android混淆proguard-rules.pro proguard-project.txt
常用的一些配置
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-ignorewarnings
#same with-ignorewarnings
-dontwarn
-keep public class * extends android.app.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
-keepclasseswithmembernames class * {
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 {
public static final android.os.Parcelable$Creator *;
}
-keepclasseswithmembers class android.app.Notification {*;}
-keepattributes Exceptions,InnerClasses,Signature
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
#don't mess the class of below
-keep class java.lang.reflect.** { *; }
# onEvent**方法不混淆
-keepclassmembers class ** {
public void onEvent*(**);
public void onEventMainThread*(**);
}
#end eventbus
#start ButterKnife
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }
-keepclasseswithmembernames class * {
@butterknife.* <fields>;
}
-keepclasseswithmembernames class * {
@butterknife.* <methods>;
}
#end ButterKnife
#------ 工程代码 begin -------------------------------------
#不混淆资源
-keep class **.R
-keep class **.R$* {
<fields>;
}
#不混淆某个类的字段和方法
-keep public class com.xxx.ClassName {
public <fields>;
public <methods>;
}
#不混淆某个包下面的所有类
-keep class com.xxx.packename.** { *; }
#native方法不混淆
-keepclasseswithmembernames class * {
native <methods>;
}
#不混淆某个类的子类中的方法
-keepclasseswithmembers class packagename.ParentClass$ChildClass {
<methods>;
}
-keepattributes Exceptions,InnerClasses,Signature
-keepattributes *Annotation*
#------ 工程代码 end ------
#------ 过滤第三方依赖 -----------------------------
#------ 过滤谷歌官方support SART------
-keep class android.support.v4.**
-keep class android.support.v7.**
-keep class android.support.design.**
-keep class android.support.annotations.**
#------ 过滤谷歌官方support END ------
-keep class com.android.volley.**
-keep class com.google.gson.**
-keep class de.greenrobot.event.**
#-keep class com.iflytek.**{*;}
-keep class com.squareup.okhttp.**
-keep class net.sqlcipher.** {*;}
#不混淆org.apache.http.legacy.jar
-keep class org.apache.http.**
-dontwarn android.net.compatibility.**
-dontwarn android.net.http.**
-dontwarn com.android.internal.http.multipart.**
-dontwarn org.apache.commons.**
-dontwarn org.apache.http.**
-keep class android.net.compatibility.**{*;}
-keep class android.net.http.**{*;}
-keep class com.android.internal.http.multipart.**{*;}
-keep class org.apache.commons.**{*;}
-keep class org.apache.http.**{*;}
#----- photoview START ------
-dontwarn uk.co.senab.photoview.**
-keep class uk.co.senab.photoview.** { *;}
#----- photoview END ------
#------ 过滤图片加载库 SART------
#-keep class com.squareup.picasso.**
#-dontwarn com.squareup.picasso.**
-keep class com.bumptech.glide.**
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
#-keep class com.makeramen.roundedimageview.**
#------ 过滤图片加载库 END------
#------ AIDL -------------------------------------------
-keep class com.xxx.AIDLnameB { *; }
-keep class com.xxx.AIDLnameB { *; }
#------------------第三方依赖库-start--------------------
-keep class okhttp3.** {*;}
-keep class pl.droidsonroids.gif.** { *; }
#------------------第三方依赖库-start---------------------
#------------------第三方jar-start------------------------
-keep class com.xxx.** {*;}
#------------------第三方jar-end--------------------------
#------------------bbb-end--------------------------------
补充信息
如果碰到了脚本弄好了,依然还是崩溃怎么办?
0x01 打印日志信息
0x02 jadx查看一下你的release.apk中混淆的结果和你预期是否一样
基本上上面的方法,就能解决混淆相关的问题.
如果是混淆编译出错
直接查看编译信息就能定位