Files
DadaoTask/android/app/build.gradle.kts
T
Steven 40415d8f76
CI / backend (push) Waiting to run
chore(android): 发布签名证书与口令随私有仓库托管
按用户要求把 dadao-release.jks 与 keystore.properties 入库,保证任何机器 clone 后可直接 assembleRelease;证书从 .local/keystore 挪到 android/keystore,.gitignore 对这两个文件开例外。仓库泄露即等于证书泄露,届时需换证书重新发版。
2026-11-11 23:29:15 +08:00

125 lines
4.9 KiB
Kotlin
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import java.util.Properties
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.plugin.compose")
id("org.jetbrains.kotlin.plugin.serialization")
}
/**
* 后端地址不走硬编码:优先读 local.properties 的 dadao.apiBase,
* 缺省指向模拟器访问宿主机的 10.0.2.2:8100。
*/
val apiBase: String = run {
val props = Properties()
val file = rootProject.file("local.properties")
if (file.exists()) file.inputStream().use { props.load(it) }
props.getProperty("dadao.apiBase") ?: "http://10.0.2.2:8100"
}
android {
namespace = "com.dadao.task"
compileSdk = 35
defaultConfig {
applicationId = "com.dadao.task"
minSdk = 26
targetSdk = 35
// 版本号是 OTA 的唯一判据:后端只比对 version_code,改这里才算"有新版本"
versionCode = 6
versionName = "0.5.1"
buildConfigField("String", "API_BASE", "\"$apiBase\"")
}
buildFeatures {
compose = true
buildConfig = true
}
/**
* 调试签名用仓库内的 keystore,而不是 ~/.android/debug.keystore。
*
* 原因:CI 与受限沙箱里 `~/.android` 常常不可写,AGP 会去建
* `debug.keystore.lock` 然后 AccessDenied,构建在 validateSigningDebug 这一步失败。
* 放在工程里就能在任何机器上直接 assembleDebug。
* 注意:这只是调试签名,release 用 android/keystore/dadao-release.jks。
*/
signingConfigs {
getByName("debug") {
storeFile = rootProject.file("keystore/debug.keystore")
storePassword = "android"
keyAlias = "androiddebugkey"
keyPassword = "android"
}
/**
* 发布签名从 android/keystore.properties 读。
*
* 证书和口令按用户要求随私有仓库托管(.gitignore 对这两个文件开了例外),
* 这样任何机器 clone 下来都能直接出正式包;代价是仓库泄露即等于证书泄露,
* 届时必须换证书并让 OTA 重新发版。
*
* 没有 keystore.properties 时回落到调试签名,assembleRelease 依然能跑,
* 只是装不上已经装了正式版的机器。
*/
create("release") {
val file = rootProject.file("keystore.properties")
if (file.exists()) {
val props = Properties()
file.inputStream().use { props.load(it) }
storeFile = rootProject.file(props.getProperty("storeFile"))
storePassword = props.getProperty("storePassword")
keyAlias = props.getProperty("keyAlias")
keyPassword = props.getProperty("keyPassword")
}
}
}
buildTypes {
release {
// 没有正式证书时回落调试签名,保证任何机器都能 assembleRelease
signingConfig = if (rootProject.file("keystore.properties").exists()) {
signingConfigs.getByName("release")
} else {
signingConfigs.getByName("debug")
}
isMinifyEnabled = false
isShrinkResources = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
}
dependencies {
implementation(platform("androidx.compose:compose-bom:2024.12.01"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation("androidx.activity:activity-compose:1.9.3")
// FileProvider(应用内升级把安装包交给系统安装器)就在 core 里,显式声明不靠传递依赖
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.7")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
// Markdown 预览用成熟库渲染,不自己写解析器
implementation("io.noties.markwon:core:4.6.2")
// 表格与删除线:Web 端正文支持,安卓不能把 | 管道符原样吐给读者
implementation("io.noties.markwon:ext-tables:4.6.2")
implementation("io.noties.markwon:ext-strikethrough:4.6.2")
// 正文图片:微信公众号转存后图片是正文里的 markdown 图,不能只当末尾附件
implementation("io.noties.markwon:image:4.6.2")
// 底部导航图标用官方 Material 图标集,不自己画五个 ImageVector
implementation("androidx.compose.material:material-icons-core")
implementation("io.coil-kt:coil-compose:2.7.0")
debugImplementation("androidx.compose.ui:ui-tooling")
}