添加release版,代码混淆配置。

This commit is contained in:
ZhanGSKen
2025-11-21 11:37:38 +08:00
parent 05850394ed
commit faf8c39fe9
5 changed files with 132 additions and 16 deletions

View File

@@ -28,12 +28,17 @@ android {
}
}
buildTypes {
release {
signingConfig signingConfigs.winboll
}
debug {
signingConfig signingConfigs.winboll
}
release {
signingConfig signingConfigs.winboll
minifyEnabled true // 开启混淆(核心开关)
shrinkResources true // 可选:移除无用资源(进一步减小体积)
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), // 官方默认规则(优化版)
'proguard-rules.pro' // 自定义规则文件
}
}
flavorDimensions "WinBoLLApp"
@@ -71,6 +76,7 @@ android {
// 2. 配置 Beta Debug 版应用包输出
//
if((variant.flavorName == "beta" && variant.buildType.name == "debug")
|| (variant.flavorName == "beta" && variant.buildType.name == "release")
|| (variant.flavorName == "stage" && variant.buildType.name == "debug")
|| (variant.flavorName == "stage" && variant.buildType.name == "release")) {
println "Project root directory: " + project.rootDir.toString()

View File

@@ -39,11 +39,10 @@ android {
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
// 确保 Java 7 兼容性(已适配项目技术栈)
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Nov 18 07:02:48 GMT 2025
#Fri Nov 21 03:35:08 GMT 2025
stageCount=1
libraryProject=libappbase
baseVersion=15.11
publishVersion=15.11.0
buildCount=7
buildCount=17
baseBetaVersion=15.11.1

View File

@@ -15,3 +15,114 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# ============================== 基础通用规则 ==============================
# 保留系统组件
-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
# 保留 WinBoLL 核心包及子类(适配你的两个包名)
#-keep public class * extends com.winboll.WinBoLLActivity
#-keep public class * extends com.winboll.WinBoLLFragment
# 主包名
-keep class cc.winboll.studio.*.** { *; }
# beta包名
-keep class cc.winboll.studio.*.beta.** { *; }
-keepclassmembers class cc.winboll.studio.*.** { *; }
-keepclassmembers class cc.winboll.studio.*.beta.** { *; }
# 保留所有类中的 public static final String TAG 字段
-keepclassmembers class * {
public static final java.lang.String TAG;
}
# 保留序列化类
-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;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
# 保留 R 文件
-keepclassmembers class **.R$* {
public static <fields>;
}
# 保留 native 方法
-keepclasseswithmembernames class * {
native <methods>;
}
# 保留注解和泛型
-keepattributes *Annotation*
-keepattributes Signature
# 屏蔽 Java 8+ 警告(适配 Java 7
-dontwarn java.lang.invoke.*
-dontwarn android.support.v8.renderscript.*
-dontwarn java.util.function.**
# ============================== 第三方框架规则 ==============================
# Retrofit + OkHttp
-keep class retrofit2.** { *; }
-keep interface retrofit2.** { *; }
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-keep class okio.** { *; }
-keepclasseswithmembers class * {
@retrofit2.http.* <methods>;
}
# Glide 4.x
-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$ImageType {
**[] $VALUES;
public *;
}
-dontwarn com.bumptech.glide.load.resource.bitmap.VideoDecoder
# GreenDAO 3.x
-keepclassmembers class * extends org.greenrobot.greendao.AbstractDao {
public static java.lang.String TABLENAME;
}
-keep class **$Properties
# 实体类包名(按实际调整)
#-keep class cc.winboll.studio.appbase.model.** { *; }
# ButterKnife 8.x
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }
-keepclasseswithmembernames class * {
@butterknife.BindView <fields>;
@butterknife.OnClick <methods>;
}
# EventBus 3.x
-keepclassmembers class ** {
@org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
# ============================== 优化与调试 ==============================
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 5
-verbose
-dontpreverify
-dontusemixedcaseclassnames
# 保留行号(便于崩溃定位)
-keepattributes SourceFile,LineNumberTable
## 米盟
-keep class com.miui.zeus.** { *; }

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Nov 18 07:02:48 GMT 2025
#Fri Nov 21 03:31:18 GMT 2025
stageCount=1
libraryProject=libappbase
baseVersion=15.11
publishVersion=15.11.0
buildCount=7
buildCount=17
baseBetaVersion=15.11.1