chore: 更新构建配置和依赖
- 更新app/build.gradle.kts构建配置 - 更新libs.versions.toml版本配置 - 更新.gitignore忽略规则 - 新增keystore.properties.template模板文件
This commit is contained in:
6
app-android/.gitignore
vendored
6
app-android/.gitignore
vendored
@@ -13,3 +13,9 @@
|
|||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
.cxx
|
.cxx
|
||||||
local.properties
|
local.properties
|
||||||
|
|
||||||
|
# 签名配置(敏感信息,不要提交)
|
||||||
|
keystore.properties
|
||||||
|
*.jks
|
||||||
|
*.keystore
|
||||||
|
release-keystore.jks
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import java.util.Properties
|
||||||
|
import java.io.FileInputStream
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.android.application)
|
alias(libs.plugins.android.application)
|
||||||
alias(libs.plugins.kotlin.android)
|
alias(libs.plugins.kotlin.android)
|
||||||
@@ -6,6 +9,13 @@ plugins {
|
|||||||
alias(libs.plugins.ksp)
|
alias(libs.plugins.ksp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载签名配置(从 keystore.properties 文件读取)
|
||||||
|
val keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||||
|
val keystoreProperties = Properties()
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.huaga.life_echo"
|
namespace = "com.huaga.life_echo"
|
||||||
compileSdk = 36
|
compileSdk = 36
|
||||||
@@ -15,21 +25,23 @@ android {
|
|||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
versionName = "1.0"
|
versionName = "1.0.0"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
// 签名配置
|
||||||
release {
|
signingConfigs {
|
||||||
isMinifyEnabled = false
|
create("release") {
|
||||||
proguardFiles(
|
if (keystorePropertiesFile.exists()) {
|
||||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
keyAlias = keystoreProperties["keyAlias"] as String
|
||||||
"proguard-rules.pro"
|
keyPassword = keystoreProperties["keyPassword"] as String
|
||||||
)
|
storeFile = file(keystoreProperties["storeFile"] as String)
|
||||||
|
storePassword = keystoreProperties["storePassword"] as String
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lint {
|
lint {
|
||||||
checkReleaseBuilds = false
|
checkReleaseBuilds = false
|
||||||
abortOnError = false
|
abortOnError = false
|
||||||
@@ -43,6 +55,46 @@ android {
|
|||||||
}
|
}
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
compose = true
|
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
|
// Image Loading
|
||||||
implementation(libs.coil.compose)
|
implementation(libs.coil.compose)
|
||||||
|
|
||||||
|
// Markdown Rendering
|
||||||
|
implementation(libs.markdown.renderer)
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
implementation(libs.accompanist.permissions)
|
implementation(libs.accompanist.permissions)
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ permissions = "0.34.0"
|
|||||||
coroutines = "1.9.0"
|
coroutines = "1.9.0"
|
||||||
serialization = "1.7.3"
|
serialization = "1.7.3"
|
||||||
coil = "2.5.0"
|
coil = "2.5.0"
|
||||||
|
markdown = "0.22.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
@@ -66,6 +67,9 @@ kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-
|
|||||||
# Image Loading
|
# Image Loading
|
||||||
coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" }
|
coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" }
|
||||||
|
|
||||||
|
# Markdown Rendering
|
||||||
|
markdown-renderer = { group = "com.mikepenz", name = "multiplatform-markdown-renderer-m3", version.ref = "markdown" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
|||||||
20
app-android/keystore.properties.template
Normal file
20
app-android/keystore.properties.template
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# 签名配置文件模板
|
||||||
|
#
|
||||||
|
# 使用说明:
|
||||||
|
# 1. 复制此文件并重命名为 keystore.properties
|
||||||
|
# 2. 修改下面的配置项为你的实际值
|
||||||
|
# 3. 不要将 keystore.properties 提交到版本控制!
|
||||||
|
#
|
||||||
|
# 注意:密钥库文件(.jks)和此配置文件都应该保密,不要公开分享
|
||||||
|
|
||||||
|
# 密钥库文件路径(相对于 app 目录或绝对路径)
|
||||||
|
storeFile=../release-keystore.jks
|
||||||
|
|
||||||
|
# 密钥库密码
|
||||||
|
storePassword=your_keystore_password
|
||||||
|
|
||||||
|
# 密钥别名
|
||||||
|
keyAlias=suiyueshishu
|
||||||
|
|
||||||
|
# 密钥密码
|
||||||
|
keyPassword=your_key_password
|
||||||
Reference in New Issue
Block a user