Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import java.util.Properties
import java.io.FileInputStream

plugins {
id("com.android.application")
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}

val keystorePropertiesFile = rootProject.file("key.properties")
val keystoreProperties = Properties().apply {
if (keystorePropertiesFile.exists()) {
load(FileInputStream(keystorePropertiesFile))
}
}

android {
namespace = "dev.shtanko.flutter_bloc_app_template"
compileSdk = flutter.compileSdkVersion
Expand Down Expand Up @@ -59,11 +69,27 @@ android {
}
}

signingConfigs {
register("release") {
enableV1Signing = true
enableV2Signing = true

storeFile = keystoreProperties["storeFile"]?.let { file(it) }
storePassword = keystoreProperties["storePassword"] as String?
keyAlias = keystoreProperties["keyAlias"] as String?
keyPassword = keystoreProperties["keyPassword"] as String?
}
}
Comment on lines +72 to +82
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use create(...) instead of register(...) for signingConfigs; add v3/v4 signing; tighten property reads.

register may not be supported on this container and can fail to configure the signing config. Also enable V3/V4 signing and use getProperty for typed reads.

Apply this diff:

-    signingConfigs {
-        register("release") {
-            enableV1Signing = true
-            enableV2Signing = true
-
-            storeFile = keystoreProperties["storeFile"]?.let { file(it) }
-            storePassword = keystoreProperties["storePassword"] as String?
-            keyAlias = keystoreProperties["keyAlias"] as String?
-            keyPassword = keystoreProperties["keyPassword"] as String?
-        }
-    }
+    signingConfigs {
+        create("release") {
+            enableV1Signing = true
+            enableV2Signing = true
+            enableV3Signing = true
+            enableV4Signing = true
+
+            keystoreProperties.getProperty("storeFile")?.let { storeFile = file(it) }
+            storePassword = keystoreProperties.getProperty("storePassword")
+            keyAlias = keystoreProperties.getProperty("keyAlias")
+            keyPassword = keystoreProperties.getProperty("keyPassword")
+        }
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
signingConfigs {
register("release") {
enableV1Signing = true
enableV2Signing = true
storeFile = keystoreProperties["storeFile"]?.let { file(it) }
storePassword = keystoreProperties["storePassword"] as String?
keyAlias = keystoreProperties["keyAlias"] as String?
keyPassword = keystoreProperties["keyPassword"] as String?
}
}
signingConfigs {
create("release") {
enableV1Signing = true
enableV2Signing = true
enableV3Signing = true
enableV4Signing = true
keystoreProperties.getProperty("storeFile")?.let { storeFile = file(it) }
storePassword = keystoreProperties.getProperty("storePassword")
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
}
}
🤖 Prompt for AI Agents
In android/app/build.gradle.kts around lines 72-82, replace
signingConfigs.register("release") with signingConfigs.create("release"), enable
V3/V4 signing by setting enableV3Signing = true and enableV4Signing = true, and
tighten property reads by using
keystoreProperties.getProperty("storeFile")/getProperty("storePassword")/getProperty("keyAlias")/getProperty("keyPassword")
(and only call file(...) if storeFile is non-null), so typed property access is
used instead of unchecked casts and the signing config is created with V1–V4
signing enabled.


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")
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("release")
}
Comment on lines +86 to 93
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Don’t hard-fail local release builds when key.properties is absent; gate signing or scope it to prod flavor.

As-is, devRelease/qaRelease will require real signing keys. Prefer a conditional fallback to debug signing locally (or assign release signing only to prod flavor).

Option A (inline fallback):

-            signingConfig = signingConfigs.getByName("release")
+            signingConfig = if (keystorePropertiesFile.exists())
+                signingConfigs.getByName("release")
+            else
+                signingConfigs.getByName("debug")

Option B (scope to prod flavor):

-    buildTypes {
-        release {
+    buildTypes {
+        release {
             ...
-            signingConfig = signingConfigs.getByName("release")
+        }
+    }
+    productFlavors {
+        // existing dev/qa/prod...
+        getByName("prod") {
+            signingConfig = signingConfigs.getByName("release")
         }
     }

Also verify that proguard-rules.pro exists and includes any Flutter/reflective keep rules to avoid runtime crashes after minification.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("release")
}
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = if (keystorePropertiesFile.exists())
signingConfigs.getByName("release")
else
signingConfigs.getByName("debug")
}
🤖 Prompt for AI Agents
In android/app/build.gradle.kts around lines 86 to 93, the release build
currently hard-fails when signing keys (key.properties) are missing causing
devRelease/qaRelease to require production keys; change the config to either (A)
conditionally apply the release signingConfig only when key.properties is
present (fall back to debug signing for local/dev builds) or (B) move/assign the
release signingConfig only to the prod flavor block so dev/qa builds use debug
signing, and ensure the signingConfig lookup is guarded to avoid exceptions;
additionally verify proguard-rules.pro exists in the project and include
necessary Flutter/reflective -keep rules to prevent runtime crashes after
minification.

}
}
Expand Down