2026-01-28 13:00:06 +08:00
|
|
|
|
import java.util.Properties
|
|
|
|
|
|
import java.io.FileInputStream
|
|
|
|
|
|
|
2026-01-07 11:57:09 +08:00
|
|
|
|
plugins {
|
|
|
|
|
|
alias(libs.plugins.android.application)
|
|
|
|
|
|
alias(libs.plugins.kotlin.android)
|
|
|
|
|
|
alias(libs.plugins.kotlin.compose)
|
|
|
|
|
|
alias(libs.plugins.kotlin.serialization)
|
|
|
|
|
|
alias(libs.plugins.ksp)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-28 13:00:06 +08:00
|
|
|
|
// 加载签名配置(从 keystore.properties 文件读取)
|
|
|
|
|
|
val keystorePropertiesFile = rootProject.file("keystore.properties")
|
|
|
|
|
|
val keystoreProperties = Properties()
|
|
|
|
|
|
if (keystorePropertiesFile.exists()) {
|
|
|
|
|
|
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-07 11:57:09 +08:00
|
|
|
|
android {
|
|
|
|
|
|
namespace = "com.huaga.life_echo"
|
|
|
|
|
|
compileSdk = 36
|
|
|
|
|
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
|
|
applicationId = "com.huaga.life_echo"
|
|
|
|
|
|
minSdk = 24
|
|
|
|
|
|
targetSdk = 36
|
|
|
|
|
|
versionCode = 1
|
2026-01-28 13:00:06 +08:00
|
|
|
|
versionName = "1.0.0"
|
2026-01-07 11:57:09 +08:00
|
|
|
|
|
|
|
|
|
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
|
|
|
|
}
|
2026-01-28 13:00:06 +08:00
|
|
|
|
|
|
|
|
|
|
// 签名配置
|
|
|
|
|
|
signingConfigs {
|
|
|
|
|
|
create("release") {
|
|
|
|
|
|
if (keystorePropertiesFile.exists()) {
|
|
|
|
|
|
keyAlias = keystoreProperties["keyAlias"] as String
|
|
|
|
|
|
keyPassword = keystoreProperties["keyPassword"] as String
|
|
|
|
|
|
storeFile = file(keystoreProperties["storeFile"] as String)
|
|
|
|
|
|
storePassword = keystoreProperties["storePassword"] as String
|
|
|
|
|
|
}
|
2026-01-07 11:57:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-01-28 13:00:06 +08:00
|
|
|
|
|
2026-01-26 11:54:17 +08:00
|
|
|
|
lint {
|
|
|
|
|
|
checkReleaseBuilds = false
|
|
|
|
|
|
abortOnError = false
|
|
|
|
|
|
}
|
2026-01-07 11:57:09 +08:00
|
|
|
|
compileOptions {
|
|
|
|
|
|
sourceCompatibility = JavaVersion.VERSION_11
|
|
|
|
|
|
targetCompatibility = JavaVersion.VERSION_11
|
|
|
|
|
|
}
|
|
|
|
|
|
kotlinOptions {
|
|
|
|
|
|
jvmTarget = "11"
|
|
|
|
|
|
}
|
|
|
|
|
|
buildFeatures {
|
|
|
|
|
|
compose = true
|
2026-01-28 13:00:06 +08:00
|
|
|
|
buildConfig = true // 启用 BuildConfig 生成
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 构建类型配置
|
|
|
|
|
|
// ⚠️ 只需修改 IS_DEBUG_MODE 即可切换环境
|
|
|
|
|
|
// true = 开发模式(显示调试UI,连接开发服务器)
|
|
|
|
|
|
// false = 生产模式(隐藏调试UI,连接生产服务器)
|
|
|
|
|
|
// URL 地址在 AppConfig.kt 中根据此值自动选择
|
|
|
|
|
|
buildTypes {
|
|
|
|
|
|
debug {
|
|
|
|
|
|
buildConfigField("Boolean", "IS_DEBUG_MODE", "true") // 开发模式
|
|
|
|
|
|
applicationIdSuffix = ".debug"
|
|
|
|
|
|
versionNameSuffix = "-debug"
|
|
|
|
|
|
}
|
|
|
|
|
|
release {
|
|
|
|
|
|
buildConfigField("Boolean", "IS_DEBUG_MODE", "false") // 生产模式
|
|
|
|
|
|
|
|
|
|
|
|
// 使用 release 签名配置
|
|
|
|
|
|
if (keystorePropertiesFile.exists()) {
|
|
|
|
|
|
signingConfig = signingConfigs.getByName("release")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
isMinifyEnabled = false
|
|
|
|
|
|
proguardFiles(
|
|
|
|
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
|
|
|
|
"proguard-rules.pro"
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// APK 文件命名
|
|
|
|
|
|
applicationVariants.all {
|
|
|
|
|
|
val variant = this
|
|
|
|
|
|
variant.outputs.all {
|
|
|
|
|
|
val output = this as com.android.build.gradle.internal.api.BaseVariantOutputImpl
|
|
|
|
|
|
val appName = "岁月史书"
|
|
|
|
|
|
val versionName = variant.versionName
|
|
|
|
|
|
val buildType = variant.buildType.name
|
|
|
|
|
|
output.outputFileName = "${appName}_v${versionName}_${buildType}.apk"
|
|
|
|
|
|
}
|
2026-01-07 11:57:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
|
|
// AndroidX Core
|
|
|
|
|
|
implementation(libs.androidx.core.ktx)
|
|
|
|
|
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
|
|
|
|
|
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
|
|
|
|
|
implementation(libs.androidx.activity.compose)
|
|
|
|
|
|
|
|
|
|
|
|
// Compose
|
|
|
|
|
|
implementation(platform(libs.androidx.compose.bom))
|
|
|
|
|
|
implementation(libs.androidx.compose.ui)
|
|
|
|
|
|
implementation(libs.androidx.compose.ui.graphics)
|
|
|
|
|
|
implementation(libs.androidx.compose.ui.tooling.preview)
|
|
|
|
|
|
implementation(libs.androidx.compose.material3)
|
|
|
|
|
|
implementation(libs.androidx.compose.material3.adaptive.navigation.suite)
|
2026-01-17 19:34:58 +08:00
|
|
|
|
// Material Icons Extended - 丰富的图标库
|
|
|
|
|
|
implementation("androidx.compose.material:material-icons-extended")
|
2026-01-07 11:57:09 +08:00
|
|
|
|
|
|
|
|
|
|
// Navigation Compose
|
|
|
|
|
|
implementation(libs.androidx.navigation.compose)
|
|
|
|
|
|
|
|
|
|
|
|
// Ktor Client
|
|
|
|
|
|
implementation(libs.ktor.client.core)
|
2026-01-23 14:02:57 +08:00
|
|
|
|
implementation(libs.ktor.client.android) // 用于普通HTTP请求
|
|
|
|
|
|
implementation(libs.ktor.client.okhttp) // 用于WebSocket(OkHttp引擎支持WebSocket)
|
2026-01-07 11:57:09 +08:00
|
|
|
|
implementation(libs.ktor.client.websockets)
|
|
|
|
|
|
implementation(libs.ktor.client.content.negotiation)
|
|
|
|
|
|
implementation(libs.ktor.serialization.kotlinx.json)
|
|
|
|
|
|
implementation(libs.ktor.client.logging)
|
|
|
|
|
|
|
|
|
|
|
|
// Room
|
|
|
|
|
|
implementation(libs.androidx.room.runtime)
|
|
|
|
|
|
implementation(libs.androidx.room.ktx)
|
|
|
|
|
|
ksp(libs.androidx.room.compiler)
|
|
|
|
|
|
|
|
|
|
|
|
// Coroutines
|
|
|
|
|
|
implementation(libs.kotlinx.coroutines.core)
|
|
|
|
|
|
implementation(libs.kotlinx.coroutines.android)
|
|
|
|
|
|
|
|
|
|
|
|
// Serialization
|
|
|
|
|
|
implementation(libs.kotlinx.serialization.json)
|
|
|
|
|
|
|
2026-01-23 14:02:57 +08:00
|
|
|
|
// Image Loading
|
|
|
|
|
|
implementation(libs.coil.compose)
|
|
|
|
|
|
|
2026-01-28 13:00:06 +08:00
|
|
|
|
// Markdown Rendering
|
|
|
|
|
|
implementation(libs.markdown.renderer)
|
|
|
|
|
|
|
2026-01-07 11:57:09 +08:00
|
|
|
|
// Permissions
|
|
|
|
|
|
implementation(libs.accompanist.permissions)
|
|
|
|
|
|
|
2026-01-18 15:58:08 +08:00
|
|
|
|
// DataStore
|
|
|
|
|
|
implementation("androidx.datastore:datastore-preferences:1.0.0")
|
|
|
|
|
|
|
2026-02-10 14:24:17 +08:00
|
|
|
|
// Payment SDKs
|
|
|
|
|
|
implementation("com.tencent.mm.opensdk:wechat-sdk-android:6.8.28") // 微信支付 SDK
|
|
|
|
|
|
implementation("com.alipay.sdk:alipaysdk-android:15.8.17") // 支付宝 SDK
|
|
|
|
|
|
|
2026-01-07 11:57:09 +08:00
|
|
|
|
// Testing
|
|
|
|
|
|
testImplementation(libs.junit)
|
|
|
|
|
|
androidTestImplementation(libs.androidx.junit)
|
|
|
|
|
|
androidTestImplementation(libs.androidx.espresso.core)
|
|
|
|
|
|
androidTestImplementation(platform(libs.androidx.compose.bom))
|
|
|
|
|
|
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
|
|
|
|
|
debugImplementation(libs.androidx.compose.ui.tooling)
|
|
|
|
|
|
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
|
|
|
|
|
}
|