fix(android): allow debug builds without key.properties
The signing configuration unconditionally cast the key.properties values to String, which crashed Gradle's config evaluation whenever key.properties was absent — even for debug builds, where release signing isn't actually used. Wrap the release signing config in an existence check, and fall back to the debug signing config when no keystore is provided. This unblocks contributors who build the project from a fresh clone.
Léo Reynal committed
May 6, 2026 at 19:33 UTC
e4a841270334b2132a8f7e2bbbb0c9d8ad75e330
1 file changed
+16
-12
android/app/build.gradle.kts
+16
-12
@@ -41,22 +41,26 @@ android {
41
multiDexEnabled = true
42
}
43
44
- signingConfigs {
45
- create("release") {
46
- keyAlias = keystoreProperties["keyAlias"] as String
47
- keyPassword = keystoreProperties["keyPassword"] as String
48
- storeFile = keystoreProperties["storeFile"]?.let { file(it) }
49
- storePassword = keystoreProperties["storePassword"] as String
44
+ signingConfigs {
45
+ if (keystorePropertiesFile.exists()) {
46
+ create("release") {
47
+ keyAlias = keystoreProperties["keyAlias"] as String
48
+ keyPassword = keystoreProperties["keyPassword"] as String
49
+ storeFile = keystoreProperties["storeFile"]?.let { file(it) }
50
+ storePassword = keystoreProperties["storePassword"] as String
51
+ }
52
}
53
}
54
53
-
54
- buildTypes {
55
+ buildTypes {
56
release {
56
- // TODO: Add your own signing config for the release build.
57
- // Signing with the debug keys for now, so `flutter run --release` works.
58
- signingConfig = signingConfigs.getByName("release")
59
- // Enable code shrinking, obfuscation, and resource shrinking for release builds to reduce app size
57
+ // Use the release signing config when key.properties is provided,
58
+ // otherwise fall back to the debug signing config so contributors
59
+ // without a keystore can still build the project.
60
+ signingConfig = if (keystorePropertiesFile.exists())
61
+ signingConfigs.getByName("release")
62
+ else
63
+ signingConfigs.getByName("debug")
64
isMinifyEnabled = true
65
isShrinkResources = true
66
}