Android 混淆文件配置

第一次配置混淆文件,盗用的别人的模板,也不知道合不合格,反正最后打包没问题,其实主要的变动是在第三方,有些使用的是官方的使用配置,有的没找到就直接使用万能写法
比如融云:
-dontwarn io.rong.push.**
-keep class io.rong.push.** {*;}
如果你不知道第三方的混淆配置,就这样写,没问题的

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/wangwei/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# 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 *;
#}
#-------------------------------------------定制化区域----------------------------------------------
#---------------------------------1.实体类---------------------------------

#本程序
-keep class com.kb.lifecool.bean.** {*;}

#-------------------------------------------------------------------------

#---------------------------------2.第三方包-------------------------------
#阿里云
-keep class com.alibaba.sdk.android.oss.** { *; }
-dontwarn okio.**
-dontwarn org.apache.commons.codec.binary.**

#融云
-dontwarn io.rong.push.**
-keep class io.rong.push.** {*;}
#图片选择
-dontwarn cn.finalteam.rxgalleryfinal.**
-keep class cn.finalteam.rxgalleryfinal.** {*;}
#地址选择
-dontwarn kankan.wheel.**
-keep class kankan.wheel.** {*;}
#
-dontwarn com.amap.api.**
-keep class com.amap.api.** {*;}
#小米推送
-dontwarn com.xiaomi.push.**
-keep class com.xiaomi.push.** {*;}
#
-dontwarn okhttp3.**
-keep class okhttp3.** {*;}
#
-dontwarn retrofit2.**
-keep class retrofit2.** {*;}

# RxJava RxAndroid
-dontwarn sun.misc.**
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
    long producerIndex;
    long consumerIndex;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
    rx.internal.util.atomic.LinkedQueueNode producerNode;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
    rx.internal.util.atomic.LinkedQueueNode consumerNode;
}

# GSON
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.examples.android.model.** { *; }

# ButterKnife
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }
-keepclasseswithmembernames class * {
    @butterknife.* <fields>;
}
-keepclasseswithmembernames class * {
    @butterknife.* <methods>;
}
#phototView
-dontwarn com.github.chrisbanes.PhotoView.**
-keep class com.github.chrisbanes.PhotoView.** {*;}
#轮播图
-dontwarn com.jude.rollviewpager.RollPagerView.**
-keep class com.jude.rollviewpager.RollPagerView.** {*;}
#剪切图片
-dontwarn com.yalantis.ucrop.**
-keep class com.yalantis.ucrop.** { *; }
-keep interface com.yalantis.ucrop.** { *; }
#提示小圆点
-dontwarn com.jauker.widget.**
-keep class ccom.jauker.widget.** { *; }
#侧滑删除
-dontwarn com.github.mcxtzhang.SwipeDelMenuLayout.**
-keep class com.github.mcxtzhang.SwipeDelMenuLayout.** { *; }
#运行时权限
-dontwarn com.zhy.m.**
-keep class com.zhy.m.** {*;}
-keep interface com.zhy.m.** { *; }
-keep class **$$PermissionProxy { *; }

#-------------------------------------------------------------------------

#---------------------------------3.与js互相调用的类------------------------



#-------------------------------------------------------------------------

#---------------------------------4.反射相关的类和方法-----------------------

-keep class com.kb.lifecool.utils.StatusBarCompat { *; }

#----------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------

#-------------------------------------------基本不用动区域--------------------------------------------
#---------------------------------基本指令区----------------------------------
#代码混淆的压缩比例,值在0-7之间
-optimizationpasses 5
#指定不去忽略非公共的库的类的成员
-dontskipnonpubliclibraryclassmembers
#生成原类名和混淆后的类名的映射文件
-printmapping proguardMapping.txt
#指定混淆是采用的算法
-optimizations !code/simplification/cast,!field/*,!class/merging/*
#不混淆Annotation
-keepattributes *Annotation*,InnerClasses
#不混淆泛型
-keepattributes Signature
#抛出异常时保留代码行号
-keepattributes SourceFile,LineNumberTable
#----------------------------------------------------------------------------
#---------------------------------默认保留区---------------------------------
-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 * extends android.view.View
-keep public class com.android.vending.licensing.ILicensingService
-keep class android.support.** {*;}

-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);
}
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
}
-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 class **.R$* {
 *;
}
-keepclassmembers class * {
    void *(**On*Event);
}
#----------------------------------------------------------------------------

#---------------------------------webview------------------------------------
-keepclassmembers class fqcn.of.javascript.interface.for.Webview {
   public *;
}
-keepclassmembers class * extends android.webkit.WebViewClient {
    public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
    public boolean *(android.webkit.WebView, java.lang.String);
}
-keepclassmembers class * extends android.webkit.WebViewClient {
    public void *(android.webkit.WebView, jav.lang.String);
}
#----------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------




猜你喜欢

转载自blog.csdn.net/a598068693/article/details/77097891