From ba742f1597ab2517f9af84016ac4d29d0a7ecc82 Mon Sep 17 00:00:00 2001 From: xfy Date: Tue, 19 May 2026 07:42:29 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E5=90=AF=E7=94=A8=20R8=20=E5=8E=8B?= =?UTF-8?q?=E7=BC=A9=E4=B8=8E=E8=B5=84=E6=BA=90=E4=BC=98=E5=8C=96=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20ProGuard=20=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - androidApp: 启用 isMinifyEnabled 和 isShrinkResources - androidApp: ABI 过滤(arm64-v8a, armeabi-v7a),关闭 buildConfig - gradle.properties: 启用并行构建、守护进程、R8 fullMode - 新建 proguard-rules.pro 保留 KMP/Compose/kotlinx.datetime 规则 Co-Authored-By: Claude Opus 4.7 (1M context) --- androidApp/build.gradle.kts | 21 +++++++++++++++++++++ androidApp/proguard-rules.pro | 20 ++++++++++++++++++++ gradle.properties | 5 ++++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 androidApp/proguard-rules.pro diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 5f63ce9..9635700 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -14,7 +14,28 @@ android { targetSdk = libs.versions.android.targetSdk.get().toInt() versionCode = 1 versionName = "1.0" + + ndk { + abiFilters += listOf("arm64-v8a", "armeabi-v7a") + } } + + buildTypes { + release { + isMinifyEnabled = true + isShrinkResources = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + signingConfig = signingConfigs.getByName("debug") + } + } + + buildFeatures { + buildConfig = false + } + compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 diff --git a/androidApp/proguard-rules.pro b/androidApp/proguard-rules.pro new file mode 100644 index 0000000..540142c --- /dev/null +++ b/androidApp/proguard-rules.pro @@ -0,0 +1,20 @@ +# Kotlin Metadata (required for KMP) +-keep class kotlin.Metadata { *; } +-keepattributes *Annotation*, Signature, InnerClasses, EnclosingMethod + +# kotlinx.datetime +-keep class kotlinx.datetime.** { *; } + +# tyme4kt (Chinese traditional calendar) +-keep class cn.tyme.** { *; } + +# Compose runtime reflective lookups +-keep class androidx.compose.runtime.** { *; } + +# ViewModel (used by CalendarViewModel) +-keep class * extends androidx.lifecycle.ViewModel { *; } + +# Keep entry point composables referenced by string name +-keepclassmembers class * { + @androidx.compose.runtime.Composable ; +} diff --git a/gradle.properties b/gradle.properties index 9c2f0cf..4177846 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,11 +6,14 @@ kotlin.daemon.jvmargs=-Xmx3072M org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8 org.gradle.configuration-cache=true org.gradle.caching=true +org.gradle.parallel=true +org.gradle.daemon=true #Android android.nonTransitiveRClass=true android.useAndroidX=true android.uniquePackageNames=false android.dependency.useConstraints=true -android.r8.strictFullModeForKeepRules=false +android.r8.strictFullModeForKeepRules=true android.generateSyncIssueWhenLibraryConstraintsAreEnabled=false +android.enableR8.fullMode=true