ButterKnife

implementation 'com.jakewharton:butterknife:9.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0'# ------------ButterKnife--------------------------------------
# Retain generated class which implement Unbinder.
# 保留生成Unbinder的生成类
-keep public class * implements butterknife.Unbinder { public <init>(**, android.view.View); }# Prevent obfuscation of types which use ButterKnife annotations since the simple name
# is used to reflectively look up the generated ViewBinding.
# 防止使用ButterKnife注释的类型的混淆,因为简单的名称用于反射地查找生成的ViewBinding
-keep class butterknife.*
-keepclasseswithmembernames class * { @butterknife.* <methods>; }
-keepclasseswithmembernames class * { @butterknife.* <fields>; }
# ------------ButterKnife--------------------------------------

Glide

implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'# ------------Glide--------------------------------------
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {**[] $VALUES;public *;
}
# for DexGuard only
# -keepresourcexmlelements manifest/application/meta-data@value=GlideModule
# ------------Glide--------------------------------------

okhttp3

implementation 'com.squareup.okhttp3:logging-interceptor:3.14.1'
implementation 'com.squareup.okhttp3:okhttp:3.14.1'# ------------okhttp3--------------------------------------
# JSR 305 annotations are for embedding nullability information.
# JSR 305注释用于嵌入可空性信息
-dontwarn javax.annotation.**# A resource is loaded with a relative path so the package of this class must be preserved.
# 资源加载了相对路径,因此必须保留此类的包。
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
# Animal Sniffer compileOnly依赖项,以确保API与旧版本的Java兼容
-dontwarn org.codehaus.mojo.animal_sniffer.*# OkHttp platform used only on JVM and when Conscrypt dependency is available.
# OkHttp平台仅在JVM上使用,并且当Conscrypt依赖性可用时。
-dontwarn okhttp3.internal.platform.ConscryptPlatform
# ------------okhttp3--------------------------------------

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;
}

retrofit2

implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.retrofit2:converter-jackson:2.5.0'implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.6'# ------------retrofit2--------------------------------------
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
# Retrofit会对通用参数进行反射。 InnerClasses需要使用Signature,并且EnclosingMethod需要使用InnerClasses。
-keepattributes Signature, InnerClasses, EnclosingMethod# Retrofit does reflection on method and parameter annotations.
# Retrofit会对方法和参数注释进行反射。
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations# Retain service method parameters when optimizing.
# 优化时保留服务方法参数。
-keepclassmembers,allowshrinking,allowobfuscation interface * {@retrofit2.http.* <methods>;
}# Ignore annotation used for build tooling.
# 忽略用于构建工具的注释。
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement# Ignore JSR 305 annotations for embedding nullability information.
# 忽略JSR 305注释以嵌入可为空性信息。
-dontwarn javax.annotation.**# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
# 由NoClassDefFoundError守护 try / catch,仅在类路径上使用。
-dontwarn kotlin.Unit# Top-level functions that can only be used by Kotlin.
# 顶级功能,只能由Kotlin使用。
-dontwarn retrofit2.KotlinExtensions# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
# 使用R8完整模式时,它不会看到Retrofit接口的子类型,因为它们是使用Proxy创建的,
# 并用null替换所有可能的值。明确地保持接口可以防止这种情况。
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
# ------------retrofit2--------------------------------------

BaseRecyclerViewAdapterHelper

# BaseRecyclerViewAdapterHelper
-keep class com.chad.library.adapter.** {
*;
}
-keep public class * extends com.chad.library.adapter.base.BaseQuickAdapter
-keep public class * extends com.chad.library.adapter.base.BaseViewHolder
-keepclassmembers public class * extends com.chad.library.adapter.base.BaseViewHolder {<init>(android.view.View);
}

Android architecture components: Lifecycle

//for lifecycle and LiveData and ViewModel
implementation "android.arch.lifecycle:runtime:1.1.1"
implementation "android.arch.lifecycle:extensions:1.1.1"annotationProcessor "android.arch.lifecycle:compiler:1.1.1"implementation "android.arch.persistence.room:runtime:1.1.1"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
// paging
implementation "android.arch.paging:runtime:1.0.1"# ------------lifecycle--------------------------------------
# Android architecture components: Lifecycle
# Android架构组件:生命周期
# LifecycleObserver's empty constructor is considered to be unused by proguard
# LifecycleObserver的空构造函数被proguard认为是未使用的
-keepclassmembers class * implements android.arch.lifecycle.LifecycleObserver {<init>(...);
}
# ViewModel's empty constructor is considered to be unused by proguard
# ViewModel的空构造函数被proguard视为未使用
-keepclassmembers class * extends android.arch.lifecycle.ViewModel {<init>(...);
}
# keep Lifecycle State and Event enums values
# 保留生命周期状态和事件枚举值
-keepclassmembers class android.arch.lifecycle.Lifecycle$State { *; }
-keepclassmembers class android.arch.lifecycle.Lifecycle$Event { *; }
# keep methods annotated with @OnLifecycleEvent even if they seem to be unused
# 保持使用@OnLifecycleEvent注释的方法,即使它们似乎未被使用
# (Mostly for LiveData.LifecycleBoundObserver.onStateChange(), but who knows)
-keepclassmembers class * {@android.arch.lifecycle.OnLifecycleEvent *;
}
-keepclassmembers class * implements android.arch.lifecycle.LifecycleObserver {<init>(...);
}-keep class * implements android.arch.lifecycle.LifecycleObserver {<init>(...);
}
-keepclassmembers class android.arch.** { *; }
-keep class android.arch.** { *; }
-dontwarn android.arch.**# paging 分页
-dontwarn android.arch.paging.DataSource
# Room 数据库
-dontwarn android.arch.persistence.room.paging.LimitOffsetDataSource# ------------lifecycle--------------------------------------

Gson

implementation 'com.google.code.gson:gson:2.8.5'##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature# For using GSON @Expose annotation
-keepattributes *Annotation*# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { <fields>; }# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {@com.google.gson.annotations.SerializedName <fields>;
}##---------------End: proguard configuration for Gson  ----------
腾讯 Bugly
# tencent-bugly
# https://bugly.qq.com/docs/user-guide/instruction-manual-android/?v=20181014122344#multidex
-dontwarn com.tencent.bugly.**
-keep public class com.tencent.bugly.**{*;}

Android 支持库

# Android Support Library
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version.  We know about them, and they are safe.
# 支持库包含对较新平台版本的引用。
# 如果此应用程序链接到较旧的平台版本,请不要警告这些。我们了解他们,他们是安全的。
-dontwarn android.support.**# support-v7-cardview
-keep class android.support.v7.widget.RoundRectDrawable { *; }# support-v7-appcompat
-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }-keep public class * extends android.support.v4.view.ActionProvider {public <init>(android.content.Context);
}# support-design
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }# support-v4
-keep class android.support.v4.** { *; }
-keep interface android.support.v4.** { *; }# supprot-v7-preference
-keepclassmembers class android.support.v7.preference.PreferenceGroupAdapter {private ** mPreferenceLayouts;
}
-keepclassmembers class android.support.v7.preference.PreferenceGroupAdapter$PreferenceLayout {private int resId;private int widgetResId;
}

通用

# Keep the BuildConfig
# todo 修改包名
-keep class com.example.BuildConfig { *; }# keep setters in Views so that animations can still work.
# 在视图中保留setter,以便动画仍然可以工作。
-keepclassmembers public class * extends android.view.View {void set*(***);*** get*();
}# We want to keep methods in Activity that could be used in the XML attribute onClick
# 我们希望在Activity中保留可在XML属性onClick中使用的方法
-keepclassmembers class * extends android.app.Activity {public void *(android.view.View);
}# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
# 对于枚举类
-keepclassmembers enum * {public static **[] values();public static ** valueOf(java.lang.String);
}-keep class * implements android.os.Parcelable {public static final android.os.Parcelable$Creator *;
}-keepclassmembers class **.R$* {public static <fields>;
}
#############################################
#
# 对于一些基本指令的添加
#
#############################################
# 代码混淆压缩比,在0~7之间,默认为5,一般不做修改
-optimizationpasses 5# 混合时不使用大小写混合,混合后的类名为小写
-dontusemixedcaseclassnames# 指定不去忽略非公共库的类
-dontskipnonpubliclibraryclasses# 这句话能够使我们的项目混淆后产生映射文件
# 包含有类名->混淆后类名的映射关系
-verbose# 指定不去忽略非公共库的类成员
-dontskipnonpubliclibraryclassmembers# 不做预校验,preverify是proguard的四个步骤之一,Android不需要preverify,去掉这一步能够加快混淆速度。
-dontpreverify# 保留Annotation不混淆
-keepattributes *Annotation*,InnerClasses# 避免混淆泛型
-keepattributes Signature# 抛出异常时保留代码行号
-keepattributes SourceFile,LineNumberTable# 指定混淆是采用的算法,后面的参数是一个过滤器
# 这个过滤器是谷歌推荐的算法,一般不做更改
-optimizations !code/simplification/cast,!field/*,!class/merging/*#############################################
#
# Android开发中一些需要保留的公共部分
#
############################################## 保留我们使用的四大组件,自定义的Application等等这些类不被混淆
# 因为这些子类都有可能被外部调用
-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# 保留support下的所有类及其内部类
-keep class android.support.** {*;}# 保留继承的
-keep public class * extends android.support.v4.**
-keep public class * extends android.support.v7.**
-keep public class * extends android.support.annotation.**# 保留R下面的资源
-keep class **.R$* {*;}# 保留本地native方法不被混淆
-keepclasseswithmembernames class * {native <methods>;
}# 保留在Activity中的方法参数是view的方法,
# 这样以来我们在layout中写的onClick就不会被影响
-keepclassmembers class * extends android.app.Activity{public void *(android.view.View);
}# 保留枚举类不被混淆
-keepclassmembers enum * {public static **[] values();public static ** valueOf(java.lang.String);
}# 保留我们自定义控件(继承自View)不被混淆
-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);
}# 保留Parcelable序列化类不被混淆
-keep class * implements android.os.Parcelable {public static final android.os.Parcelable$Creator *;
}# 保留Serializable序列化的类不被混淆
-keepclassmembers class * implements java.io.Serializable {static final long serialVersionUID;private static final java.io.ObjectStreamField[] serialPersistentFields;!static !transient <fields>;!private <fields>;!private <methods>;private void writeObject(java.io.ObjectOutputStream);private void readObject(java.io.ObjectInputStream);java.lang.Object writeReplace();java.lang.Object readResolve();
}# 对于带有回调函数的onXXEvent、**On*Listener的,不能被混淆
-keepclassmembers class * {void *(**On*Event);void *(**On*Listener);
}# webView处理,项目中没有使用到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);
}# 移除Log类打印各个等级日志的代码,打正式包的时候可以做为禁log使用,这里可以作为禁止log打印的功能使用
# 记得proguard-android.txt中一定不要加-dontoptimize才起作用
# 另外的一种实现方案是通过BuildConfig.DEBUG的变量来控制
-assumenosideeffects class android.util.Log {public static int v(...);public static int i(...);public static int w(...);public static int d(...);public static int e(...);
}#-----------处理实体类---------------
# 在开发的时候我们可以将所有的实体类放在一个包内,这样我们写一次混淆就行了。
-keep public class com.ljd.example.entity.** {public void set*(***);public *** get*();public *** is*();
}

Android 第三方库常用混淆相关推荐

  1. Android第三方库

    Android开源库 自己一直很喜欢Android开发,就如博客签名一样, 我是程序猿,我为自己代言 . 在摸索过程中,GitHub上搜集了很多很棒的android第三方库,推荐给在苦苦寻找的开发者, ...

  2. android第三方图标库,Android 第三方库AgentWeb的使用

    Android 第三方库AgentWeb的使用 一:前言 Android开发经常会用到WebView,用于加载网页.系统自带的WebView性能和流畅度都一般,AgentWeb是一款第三方的WebVi ...

  3. 常用Android第三方库推荐

    目录 1 BaseRecyclerViewAdapterHelper 2  Glide开源图片加载类库 3 OKhttp 网络请求框架 4  Retrofit  网络请求框架 5  EventBus事 ...

  4. Android 第三方库--2017年Android开源项目及库汇总

    转自:http://blog.csdn.net/jsonnan/article/details/62215287 东西有点多,但是资源绝对nice,自己都全部亲身体验过了,大家可放心使用 github ...

  5. Android 第三方库前100

    本文转自:https://github.com/Freelander/Android_Data/blob/master/Android-Librarys-Top-100.md 本项目主要对目前 Git ...

  6. 2017年伊始,你需要尝试的25个Android第三方库

    作者:Jack-sen,原文地址:http://blog.csdn.net/crazy1235/article/details/55805071 medium 平台有位作者总结了2017年初最棒最受欢 ...

  7. Android第三方库收藏汇总

    AndroidUtils 原文:原文 个人在Github上收藏的一些第三方库,做一个说明记录,方便自己查找. 文章目录开发规范:图片剪裁/编辑:图片压缩:汉字转拼音:JS与Native交互:视频播放器 ...

  8. Android 第三方库AgentWeb的使用

    一:前言 Android开发经常会用到WebView,用于加载网页.系统自带的WebView性能和流畅度都一般,AgentWeb是一款第三方的WebView,性能比系统自带的要好,功能也更多. Age ...

  9. android c pdf,我把所有Android第三方库整理成了PDF,送大厂面经一份!

    目录 想要成为一名优秀的Android开发,你需要一份完备的知识体系,在这里,让我们一起成长为自己所想的那样. PagerAdapter 介绍 ViwePager 缓存策略 ViewPager 布局处 ...

最新文章

  1. AI 一分钟 | 法拉第未来称年底前交付首量FF91,你还相信贾跃亭吗?
  2. grub legacy
  3. spring中事务配置的3种方式-2
  4. 动态规划算法入门---java版
  5. SAP CRM WebClient UI element id generation logic
  6. Nginx location执行顺序和匹配规则
  7. POJ 1887 (DP)
  8. [2005.04.28 13:36:04] 孤岛热浪的联想
  9. linux c 调用c程序,Linux C调用C++库(用C封装C++接口)
  10. 十分钟了解websql和indexedDB
  11. ACM算法竞赛入门 概述
  12. html静态网页实例一(附完整代码)
  13. Python 实现 Discuz论坛附件下载权限绕过漏洞
  14. GoodERP交付手册:CRM模块交付
  15. tab按钮样式 vue_vant 解决tab切换插件标题样式自定义的问题
  16. 利用Excel绘制超好看的直方图与正态分布曲线
  17. perfmon的使用及性能分析
  18. 闭锁 java_Java并发编程之闭锁
  19. 组织行为学笔记(5)——知觉与个体决策
  20. Matlab/simulink、Saber及PSpice学习比较

热门文章

  1. 神经网络中的偏置项b到底是什么?
  2. 【TouchYourself】1.0版本的博客记录观后感
  3. 解决android开发在大屏手机图片出现内存溢出
  4. 解决服务器windows主机显示本地连接网络电缆没插好问题
  5. django ORM多表联合查询
  6. VBA CreateObject 各种类型文件(transfer)
  7. TLD目标跟踪算法学习(一)
  8. mybatis的SQL语句构建器
  9. 【颠倒黄白】农村学生的竞争优势 http://www.infzm.com/content/93475
  10. 【甜椒ACM】博弈论入门(Nim、sg定理)