build(android): 接入正式签名配置 + 版本号改为 1.1.0-dev.1 (2)

- app/build.gradle.kts 读取 android/key.properties(不存在时回退 debug keystore)
- .gitignore 忽略 key.properties / keystore / *.jks
- pubspec: version 1.1.0-dev.1+2

注意:key.properties 与 keystore 文件由开发者本地生成,不入库。
生成后 flutter build apk --release 即为正式签名包。
This commit is contained in:
2026-10-24 00:11:53 +08:00
parent 30111a5f0c
commit ff41769c56
3 changed files with 36 additions and 3 deletions
+6
View File
@@ -45,3 +45,9 @@ bug-todo.txt
# ---------- 服务器/监控日志(本地参考,不上传) ---------- # ---------- 服务器/监控日志(本地参考,不上传) ----------
monitor-log-*.csv monitor-log-*.csv
# ---------- 签名材料(绝不入库) ----------
android/key.properties
android/keystore/
*.jks
*.keystore
+29 -2
View File
@@ -4,6 +4,18 @@ plugins {
id("dev.flutter.flutter-gradle-plugin") id("dev.flutter.flutter-gradle-plugin")
} }
// 正式签名:android/key.properties(不入库)
// 文件缺失时自动回退到 debug keystore,保证 clone 下来也能直接构建
import java.io.FileInputStream
import java.util.Properties
val keystorePropertiesFile = rootProject.file("key.properties")
val keystoreProperties = Properties()
val hasReleaseKeystore = keystorePropertiesFile.exists()
if (hasReleaseKeystore) {
FileInputStream(keystorePropertiesFile).use { keystoreProperties.load(it) }
}
android { android {
namespace = "com.lxh.qingting_player" namespace = "com.lxh.qingting_player"
compileSdk = flutter.compileSdkVersion compileSdk = flutter.compileSdkVersion
@@ -47,6 +59,17 @@ android {
resValues = true resValues = true
} }
signingConfigs {
create("release") {
if (hasReleaseKeystore) {
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
storeFile = rootProject.file(keystoreProperties.getProperty("storeFile"))
storePassword = keystoreProperties.getProperty("storePassword")
}
}
}
buildTypes { buildTypes {
debug { debug {
// 测试包与正式包并存安装:com.lxh.qingting_player.dev // 测试包与正式包并存安装:com.lxh.qingting_player.dev
@@ -56,9 +79,13 @@ android {
resValue("string", "app_name", "清听 Dev") resValue("string", "app_name", "清听 Dev")
} }
release { release {
// TODO: 上线前换成正式签名(当前沿用 debug keystore)
resValue("string", "app_name", "清听") resValue("string", "app_name", "清听")
signingConfig = signingConfigs.getByName("debug") // 有 key.properties 就用正式签名,否则回退 debug(仅本机调试用)
signingConfig = if (hasReleaseKeystore) {
signingConfigs.getByName("release")
} else {
signingConfigs.getByName("debug")
}
} }
} }
} }
+1 -1
View File
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.1.0+1 version: 1.1.0-dev.1+2
environment: environment:
sdk: ^3.0.0 sdk: ^3.0.0