Add signing configuration support in build.gradle.kts

This commit is contained in:
zjs81
2026-01-15 18:41:06 -07:00
parent 7c33647119
commit 614f3d4601
+25 -3
View File
@@ -1,3 +1,5 @@
import java.util.Properties
plugins { plugins {
id("com.android.application") id("com.android.application")
id("kotlin-android") id("kotlin-android")
@@ -5,6 +7,12 @@ plugins {
id("dev.flutter.flutter-gradle-plugin") id("dev.flutter.flutter-gradle-plugin")
} }
val keystoreProperties = Properties()
val keystorePropertiesFile = rootProject.file("key.properties")
if (keystorePropertiesFile.exists()) {
keystorePropertiesFile.inputStream().use { keystoreProperties.load(it) }
}
android { android {
namespace = "com.meshcore.meshcore_open" namespace = "com.meshcore.meshcore_open"
compileSdk = flutter.compileSdkVersion compileSdk = flutter.compileSdkVersion
@@ -40,11 +48,25 @@ android {
// } // }
} }
signingConfigs {
create("release") {
val storeFilePath = keystoreProperties["storeFile"] as String?
if (storeFilePath != null) {
storeFile = file(storeFilePath)
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. signingConfig = if (keystorePropertiesFile.exists()) {
// Signing with the debug keys for now, so `flutter run --release` works. signingConfigs.getByName("release")
signingConfig = signingConfigs.getByName("debug") } else {
signingConfigs.getByName("debug")
}
} }
} }