mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Add Android release signing config for Play Store
Release builds were signed with the debug key, which Play rejects. Load an upload keystore from android/key.properties (gitignored) and use it for the release signing config, falling back to the debug key when the file is absent so `flutter run --release` still works without a keystore. Add key.properties.example documenting the keytool setup and a build_android_release.sh helper that builds the signed AAB and refuses to run when key.properties is missing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
468bf7d777
commit
11a964bd37
@@ -1,3 +1,5 @@
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("kotlin-android")
|
||||
@@ -5,6 +7,15 @@ plugins {
|
||||
id("dev.flutter.flutter-gradle-plugin")
|
||||
}
|
||||
|
||||
// Load the upload keystore credentials from key.properties (gitignored, never
|
||||
// committed). Absent on machines without the keystore (e.g. CI or a fresh
|
||||
// clone), in which case release builds fall back to the debug signing key.
|
||||
val keystoreProperties = Properties()
|
||||
val keystorePropertiesFile = rootProject.file("key.properties")
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystorePropertiesFile.inputStream().use { keystoreProperties.load(it) }
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "net.oottsecurity.app"
|
||||
compileSdk = flutter.compileSdkVersion
|
||||
@@ -31,11 +42,30 @@ android {
|
||||
versionName = flutter.versionName
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
// Only registered when key.properties is present; otherwise release
|
||||
// builds fall back to the debug key below.
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
create("release") {
|
||||
keyAlias = keystoreProperties["keyAlias"] as String
|
||||
keyPassword = keystoreProperties["keyPassword"] as String
|
||||
storeFile = file(keystoreProperties["storeFile"] as String)
|
||||
storePassword = keystoreProperties["storePassword"] as String
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
// Sign with the upload key for Play Store builds. When key.properties
|
||||
// is missing, fall back to the debug key so `flutter run --release`
|
||||
// still works locally.
|
||||
signingConfig =
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
signingConfigs.getByName("release")
|
||||
} else {
|
||||
signingConfigs.getByName("debug")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user