AndroidApp/app/proguard-rules.pro

91 lines
2.8 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
# Retrofit
# Retrofit
# Retrofit
# 保留Retrofit接口
# 保留所有Retrofit接口及注解
# ========== 基础保留 ==========
-keepattributes Signature, RuntimeVisibleAnnotations, InnerClasses, EnclosingMethod
-keepnames class * { @retrofit2.http.* <methods>; }
# ========== Retrofit 保留规则 ==========
-keep interface ** { @retrofit2.http.* <methods>; }
-keep class retrofit2.** { *; }
-keepclasseswithmembers class * {
@retrofit2.* <methods>;
}
# ========== Gson 保留规则 ==========
-keep class com.google.gson.** { *; }
-keep class com.google.gson.stream.** { *; }
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keepclassmembers class * {
@com.google.gson.annotations.SerializedName <fields>;
}
# ========== 您的项目特定规则 ==========
# 替换 com.yourpackage 为您的实际包名
-keep class com.example.myapplication.api.** { *; } # 接口包
-keep class com.example.myapplication.model.** { *; } # 模型包
-keepclassmembers class com.example.myapplication.model.** { # 保留模型类成员
*;
}
# ========== Kotlin 支持 ==========
-keep class kotlin.** { *; }
-keep class kotlinx.** { *; }
-keepclassmembers class **$WhenMappings {
<fields>;
}
# ========== AndroidX 支持 ==========
-keep class androidx.** { *; }
-dontwarn androidx.**
# ========== 第三方库警告抑制 ==========
-dontwarn javax.lang.model.element.Modifier
-dontwarn org.jetbrains.annotations.**
-dontwarn okio.**
-dontwarn okhttp3.**
-dontwarn retrofit2.**
# ========== 其他必要保留 ==========
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
# 保留数据库相关类
-keep class com.example.myapplication.DataBase.** { *; }
-keep class com.example.myapplication.Service.** { *; }
-keep class com.example.myapplication.Tool.** { *; }