From 78d3d455703d4216c0af76eedf8197d74f45a8ab Mon Sep 17 00:00:00 2001 From: Developer Date: Mon, 31 Aug 2026 06:40:23 -0400 Subject: [PATCH] FIX: Establish working production release signing --- android/app/build.gradle.kts | 68 ++++++++++++++++++++++++++------- android/key.properties.template | 7 ++++ 2 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 android/key.properties.template diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 39376aa..737d83f 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -1,11 +1,48 @@ +import java.io.FileInputStream +import java.util.Properties + plugins { id("com.android.application") - // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id("dev.flutter.flutter-gradle-plugin") + id("com.google.gms.google-services") } +val keystoreProperties = Properties() +val keystorePropertiesFile = rootProject.file("key.properties") + +if (!keystorePropertiesFile.exists()) { + throw GradleException( + "Missing android/key.properties. " + + "Create it from android/key.properties.template." + ) +} + +FileInputStream(keystorePropertiesFile).use { + keystoreProperties.load(it) +} + +fun requiredKeystoreProperty(name: String): String { + val value = keystoreProperties.getProperty(name)?.trim() + + println("MotorSignal signing property [$name]: ${if (value.isNullOrEmpty()) "" else ""}") + + if (value.isNullOrEmpty()) { + println("Properties actually loaded by Gradle: ${keystoreProperties.keys}") + throw GradleException( + "Missing $name in android/key.properties" + ) + } + + return value +} + +val releaseStorePassword = requiredKeystoreProperty("storePassword") +val releaseKeyPassword = requiredKeystoreProperty("keyPassword") +val releaseKeyAlias = requiredKeystoreProperty("keyAlias") +val releaseStoreFile = requiredKeystoreProperty("storeFile") + android { - namespace = "com.example.motorcycle_dash" + namespace = "app.motorsignal.motorcycle" compileSdk = 37 ndkVersion = flutter.ndkVersion @@ -15,25 +52,30 @@ android { } defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId = "com.example.motorcycle_dash" - // You can update the following values to match your application needs. - // For more information, see: https://flutter.dev/to/review-gradle-config. + applicationId = "app.motorsignal.motorcycle" minSdk = flutter.minSdkVersion targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode versionName = flutter.versionName } - 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") - } + signingConfigs { + create("release") { + keyAlias = releaseKeyAlias + keyPassword = releaseKeyPassword + storePassword = releaseStorePassword + storeFile = rootProject.file(releaseStoreFile) + storeType = "PKCS12" } } + buildTypes { + release { + signingConfig = signingConfigs.getByName("release") + } +} +} + kotlin { compilerOptions { jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 @@ -42,4 +84,4 @@ kotlin { flutter { source = "../.." -} +} \ No newline at end of file diff --git a/android/key.properties.template b/android/key.properties.template new file mode 100644 index 0000000..3b697f0 --- /dev/null +++ b/android/key.properties.template @@ -0,0 +1,7 @@ +# MotorSignal Android Production Signing Key Configuration Template +# Copy this file to `android/key.properties` (which is gitignored) and fill with your actual keystore details. + +storePassword=YOUR_KEYSTORE_PASSWORD +keyPassword=YOUR_KEY_PASSWORD +keyAlias=motorsignal_upload_key +storeFile=../upload-keystore.jks