136 lines
4.5 KiB
Prolog
136 lines
4.5 KiB
Prolog
# Add project specific ProGuard rules here.
|
||
# You can control the set of applied configuration files using the
|
||
# proguardFiles setting in build.gradle.
|
||
#
|
||
# For more details, see
|
||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||
|
||
# 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 *;
|
||
#}
|
||
|
||
# Uncomment this to preserve the line number information for
|
||
# debugging stack traces.
|
||
#-keepattributes SourceFile,LineNumberTable
|
||
|
||
# If you keep the line number information, uncomment this to
|
||
# hide the original source file name.
|
||
#-renamesourcefileattribute SourceFile
|
||
|
||
-dontwarn com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.YouTubePlayerListener
|
||
|
||
# 代码优化迭代次数,默认5次,一般无需修改
|
||
-optimizationpasses 5
|
||
# 混淆时不使用大小写混合的类名
|
||
-dontusemixedcaseclassnames
|
||
# 不忽略非公共库的类及其成员
|
||
-dontskipnonpubliclibraryclasses
|
||
-dontskipnonpubliclibraryclassmembers
|
||
# 不进行预校验(Android不需要,可加快速度)
|
||
-dontpreverify
|
||
# 打印详细的处理信息,便于调试
|
||
-verbose
|
||
|
||
# 混淆时采用的算法(谷歌推荐过滤器)
|
||
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
|
||
# 优化时允许访问并修改有修饰符的类和类的成员
|
||
-allowaccessmodification
|
||
|
||
# 保留重要属性:注解(对JSON解析、依赖注入框架关键)、泛型签名、异常信息、源码文件名和行号(便于崩溃追踪)
|
||
-keepattributes *Annotation*, Signature, Exceptions, InnerClasses, SourceFile, LineNumberTable
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# 保留四大组件、Application等核心类,因其在AndroidManifest.xml中注册,类名不能被混淆[1,2](@ref)
|
||
-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
|
||
|
||
# 保留自定义View的构造函数,防止在XML布局中被调用时因混淆而出错[2,5](@ref)
|
||
-keepclasseswithmembers class * {
|
||
public <init>(android.content.Context, android.util.AttributeSet);
|
||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||
}
|
||
# 保留View的setter和getter方法,以保证属性动画正常工作[2,6](@ref)
|
||
-keepclassmembers class * extends android.view.View {
|
||
void set*(***);
|
||
*** get*();
|
||
}
|
||
|
||
# 保留R文件中的静态字段,避免通过反射获取资源ID时失败[2,7](@ref)
|
||
-keepclassmembers class **.R$* {
|
||
public static <fields>;
|
||
}
|
||
|
||
|
||
|
||
|
||
# 保留所有Native方法名,确保JNI调用能正确链接[2,3](@ref)
|
||
-keepclasseswithmembernames class * {
|
||
native <methods>;
|
||
}
|
||
|
||
# 保留枚举类的方法,枚举类型默认依赖固定的values()和valueOf方法[2,6](@ref)
|
||
-keepclassmembers enum * {
|
||
public static **[] values();
|
||
public static ** valueOf(java.lang.String);
|
||
}
|
||
|
||
# 保留Parcelable序列化接口的Creator字段[2,5](@ref)
|
||
-keep class * implements android.os.Parcelable {
|
||
public static final android.os.Parcelable$Creator *;
|
||
}
|
||
# 保留Serializable序列化类的特定成员[2,4](@ref)
|
||
-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();
|
||
}
|
||
|
||
# 保留在布局XML中使用的onClick方法[2,3](@ref)
|
||
-keepclassmembers class * extends android.app.Activity {
|
||
public void *(android.view.View);
|
||
}
|
||
|
||
# 保留通过JavascriptInterface注解暴露给WebView的方法[2,8](@ref)
|
||
-keepclassmembers class * {
|
||
@android.webkit.JavascriptInterface <methods>;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# Gson
|
||
-keep class com.google.gson.** { *; }
|
||
-keep class sun.misc.Unsafe { *; }
|
||
-keep class com.yourpackage.model.** { *; } # 保留你的实体类
|
||
|
||
# OkHttp & Okio
|
||
-dontwarn okhttp3.**
|
||
-keep class okhttp3.** { *; }
|
||
-dontwarn okio.**
|
||
-keep class okio.** { *; }
|
||
|
||
# Retrofit
|
||
-dontwarn retrofit2.**
|
||
-keep class retrofit2.** { *; }
|
||
-keepattributes Signature, Exceptions
|
||
|
||
# 忽略第三方库的警告(如果确定某些警告无害)
|
||
-dontwarn android.support.**
|
||
-dontwarn androidx.** |