chore: 更新构建配置和依赖
- 更新app/build.gradle.kts构建配置 - 更新libs.versions.toml版本配置 - 更新.gitignore忽略规则 - 新增keystore.properties.template模板文件
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import java.util.Properties
|
||||
import java.io.FileInputStream
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
@@ -6,6 +9,13 @@ plugins {
|
||||
alias(libs.plugins.ksp)
|
||||
}
|
||||
|
||||
// 加载签名配置(从 keystore.properties 文件读取)
|
||||
val keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
val keystoreProperties = Properties()
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.huaga.life_echo"
|
||||
compileSdk = 36
|
||||
@@ -15,21 +25,23 @@ android {
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
versionName = "1.0.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
|
||||
// 签名配置
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lint {
|
||||
checkReleaseBuilds = false
|
||||
abortOnError = false
|
||||
@@ -43,6 +55,46 @@ android {
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +142,9 @@ dependencies {
|
||||
// Image Loading
|
||||
implementation(libs.coil.compose)
|
||||
|
||||
// Markdown Rendering
|
||||
implementation(libs.markdown.renderer)
|
||||
|
||||
// Permissions
|
||||
implementation(libs.accompanist.permissions)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user