197 lines
6.0 KiB
Prolog
197 lines
6.0 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
|
|
|
|
|
|
|
|
#禁用所有优化规则,查看混淆后 APK是否可以正常工作
|
|
#-dontoptimize
|
|
|
|
# 基础混淆配置
|
|
-optimizationpasses 5
|
|
-dontusemixedcaseclassnames
|
|
-dontskipnonpubliclibraryclasses
|
|
-dontskipnonpubliclibraryclassmembers
|
|
-dontpreverify
|
|
-verbose
|
|
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
|
|
|
# 保留注解、泛型、异常信息
|
|
-keepattributes *Annotation*,Signature,Exception
|
|
-keepattributes InnerClasses,EnclosingMethod
|
|
|
|
# Android基础组件保护
|
|
-keep public class * extends android.app.Activity
|
|
-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
|
|
|
|
# 保留Activity生命周期方法
|
|
-keepclassmembers public class * extends android.app.Activity {
|
|
public void *(android.view.View);
|
|
public void on*(...);
|
|
}
|
|
|
|
# 保留Service生命周期方法
|
|
-keepclassmembers public class * extends android.app.Service {
|
|
public void on*(...);
|
|
}
|
|
|
|
# 保留BroadcastReceiver接收方法
|
|
-keepclassmembers class * extends android.content.BroadcastReceiver {
|
|
public void onReceive(android.content.Context, android.content.Intent);
|
|
}
|
|
|
|
# 保留ContentProvider方法
|
|
-keepclassmembers class * extends android.content.ContentProvider {
|
|
public android.net.Uri insert(android.net.Uri, android.content.ContentValues);
|
|
public int update(android.net.Uri, android.content.ContentValues, java.lang.String, java.lang.String[]);
|
|
public int delete(android.net.Uri, java.lang.String, java.lang.String[]);
|
|
public android.database.Cursor query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String);
|
|
}
|
|
|
|
# 保留R文件
|
|
-keep class **.R$* { *; }
|
|
|
|
# Parcelable和Serializable支持
|
|
-keep class * implements android.os.Parcelable {
|
|
public static final android.os.Parcelable$Creator *;
|
|
}
|
|
-keepclassmembers class * implements java.io.Serializable {
|
|
static final long serialVersionUID;
|
|
private static final java.io.ObjectStreamField[] serialPersistentFields;
|
|
!static !transient <fields>;
|
|
private void writeObject(java.io.ObjectOutputStream);
|
|
private void readObject(java.io.ObjectInputStream);
|
|
java.lang.Object writeReplace();
|
|
java.lang.Object readResolve();
|
|
}
|
|
|
|
# Kotlin特定规则
|
|
-keep class kotlin.** { *; }
|
|
-keep class kotlin.Metadata { *; }
|
|
-dontwarn kotlin.**
|
|
-keepclassmembers class **$WhenMappings {
|
|
<fields>;
|
|
}
|
|
-keepclassmembers class kotlinx.coroutines.internal.MainCoroutineDispatcherFactory {
|
|
public <init>();
|
|
}
|
|
-keepclassmembers class kotlinx.coroutines.CoroutineExceptionHandler {
|
|
public <init>();
|
|
}
|
|
|
|
# 数据类保护(根据项目实际数据类包名调整)
|
|
-keep class com.abbidot.tracker.data.** { *; }
|
|
-keep class com.abbidot.tracker.model.** { *; }
|
|
|
|
# ViewBinding支持
|
|
-keep class com.abbidot.tracker.databinding.** { *; }
|
|
|
|
# Hilt依赖注入
|
|
-keep class dagger.hilt.android.lifecycle.HiltViewModelFactory { *; }
|
|
-keep class * extends dagger.hilt.android.lifecycle.HiltViewModel { *; }
|
|
-keep @dagger.hilt.android.lifecycle.HiltViewModel class * { *; }
|
|
-keep @dagger.hilt.android.AndroidEntryPoint class * { *; }
|
|
-keep @dagger.Module class * { *; }
|
|
-keep @dagger.hilt.EntryPoint class * { *; }
|
|
|
|
# Room数据库
|
|
-keep class * extends androidx.room.RoomDatabase { *; }
|
|
-keep @androidx.room.Entity class * { *; }
|
|
-keep interface * extends androidx.room.Dao { *; }
|
|
-keepclassmembers class * extends androidx.room.RoomDatabase {
|
|
<methods>;
|
|
}
|
|
|
|
# 第三方库规则
|
|
|
|
# Coil图片加载
|
|
-keep class io.coil.** { *; }
|
|
-dontwarn io.coil.**
|
|
|
|
# Lottie动画
|
|
-keep class com.airbnb.lottie.** { *; }
|
|
-dontwarn com.airbnb.lottie.**
|
|
|
|
# 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
|
|
|
|
# Mapbox
|
|
-keep class com.mapbox.** { *; }
|
|
-dontwarn com.mapbox.**
|
|
|
|
# 百度地图
|
|
-keep class com.baidu.** { *; }
|
|
-keep class vi.com.gdi.bgl.android.** { *; }
|
|
-dontwarn com.baidu.**
|
|
|
|
# 极光推送
|
|
-keep class cn.jiguang.** { *; }
|
|
-dontwarn cn.jiguang.**
|
|
|
|
# Stripe支付
|
|
-keep class com.stripe.** { *; }
|
|
-dontwarn com.stripe.**
|
|
|
|
# Braintree支付
|
|
-keep class com.braintreepayments.** { *; }
|
|
-dontwarn com.braintreepayments.**
|
|
|
|
# 微信SDK
|
|
-keep class com.tencent.mm.opensdk.** { *; }
|
|
-keep class com.tencent.wxop.** { *; }
|
|
-keep class com.tencent.mm.sdk.** { *; }
|
|
|
|
# 支付宝SDK
|
|
-keep class com.alipay.** { *; }
|
|
-dontwarn com.alipay.**
|
|
|
|
# DFU升级库
|
|
-keep class no.nordicsemi.android.** { *; }
|
|
-dontwarn no.nordicsemi.android.**
|
|
|
|
# 测试相关
|
|
-dontnote junit.framework.**
|
|
-dontnote junit.runner.**
|
|
-dontwarn android.test.**
|
|
-dontwarn android.support.test.**
|
|
-dontwarn org.junit.**
|
|
|
|
# 移除日志(发布版)
|
|
-assumenosideeffects class android.util.Log {
|
|
public static boolean isLoggable(java.lang.String, int);
|
|
public static int v(...);
|
|
public static int i(...);
|
|
public static int w(...);
|
|
public static int d(...);
|
|
public static int e(...);
|
|
}
|
|
|
|
# 混淆映射输出
|
|
-printmapping proguardMapping.txt
|
|
-printseeds proguardSeeds.txt
|
|
-printusage proguardUsage.txt |