android: wire release signing from key.properties (debug fallback)

Firebase App Distribution 배포용 정식 서명 키 지원. android/key.properties가
있으면 release 키로 서명하고, 없으면(다른 개발자/CI) debug 키로 폴백한다.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
theorose49 2026-06-30 15:56:14 +09:00
parent 8c479108bd
commit 9e8d599dc2

View File

@ -1,9 +1,21 @@
import java.util.Properties
import java.io.FileInputStream
plugins { plugins {
id("com.android.application") id("com.android.application")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin") id("dev.flutter.flutter-gradle-plugin")
} }
// 릴리스 서명 키: android/key.properties 에서 읽음(파일은 git 제외).
// 파일이 없으면(다른 개발자/CI) debug 키로 폴백하여 빌드는 깨지지 않게 함.
val keystoreProperties = Properties()
val keystorePropertiesFile = rootProject.file("key.properties")
val hasReleaseKeystore = keystorePropertiesFile.exists()
if (hasReleaseKeystore) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}
android { android {
namespace = "com.specialpartners.spin" namespace = "com.specialpartners.spin"
compileSdk = flutter.compileSdkVersion compileSdk = flutter.compileSdkVersion
@ -25,11 +37,25 @@ android {
versionName = flutter.versionName versionName = flutter.versionName
} }
signingConfigs {
if (hasReleaseKeystore) {
create("release") {
storeFile = file(keystoreProperties["storeFile"] as String)
storePassword = keystoreProperties["storePassword"] as String
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
}
}
}
buildTypes { buildTypes {
release { release {
// TODO: Add your own signing config for the release build. // key.properties 있으면 release 키로 서명, 없으면 debug 키 폴백.
// Signing with the debug keys for now, so `flutter run --release` works. signingConfig = if (hasReleaseKeystore) {
signingConfig = signingConfigs.getByName("debug") signingConfigs.getByName("release")
} else {
signingConfigs.getByName("debug")
}
} }
} }
} }