From ff41769c563eced637d1b5c67fffe6e44ec0444a Mon Sep 17 00:00:00 2001 From: lxh2875931338 Date: Sat, 24 Oct 2026 00:11:53 +0800 Subject: [PATCH] =?UTF-8?q?build(android):=20=E6=8E=A5=E5=85=A5=E6=AD=A3?= =?UTF-8?q?=E5=BC=8F=E7=AD=BE=E5=90=8D=E9=85=8D=E7=BD=AE=20+=20=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E6=94=B9=E4=B8=BA=201.1.0-dev.1=20(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 即为正式签名包。 --- .gitignore | 6 ++++++ android/app/build.gradle.kts | 31 +++++++++++++++++++++++++++++-- pubspec.yaml | 2 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index da0bd23..f52d06d 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,9 @@ bug-todo.txt # ---------- 服务器/监控日志(本地参考,不上传) ---------- monitor-log-*.csv + +# ---------- 签名材料(绝不入库) ---------- +android/key.properties +android/keystore/ +*.jks +*.keystore diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 1476e29..fffc60c 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -4,6 +4,18 @@ plugins { 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 { namespace = "com.lxh.qingting_player" compileSdk = flutter.compileSdkVersion @@ -47,6 +59,17 @@ android { 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 { debug { // 测试包与正式包并存安装:com.lxh.qingting_player.dev @@ -56,9 +79,13 @@ android { resValue("string", "app_name", "清听 Dev") } release { - // TODO: 上线前换成正式签名(当前沿用 debug keystore) resValue("string", "app_name", "清听") - signingConfig = signingConfigs.getByName("debug") + // 有 key.properties 就用正式签名,否则回退 debug(仅本机调试用) + signingConfig = if (hasReleaseKeystore) { + signingConfigs.getByName("release") + } else { + signingConfigs.getByName("debug") + } } } } diff --git a/pubspec.yaml b/pubspec.yaml index 03afda5..7aa604d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 # 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. -version: 1.1.0+1 +version: 1.1.0-dev.1+2 environment: sdk: ^3.0.0