From f4b905cd42164a13cdb775014c29c529e763d2c8 Mon Sep 17 00:00:00 2001 From: Vaibhav Surve Date: Tue, 29 Jul 2025 09:57:24 +0530 Subject: [PATCH] feat(build): enhance Gradle configuration with keystore properties and release signing setup --- android/app/build.gradle | 49 +++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 86a56ac..694a2e1 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -5,40 +5,73 @@ plugins { id "dev.flutter.flutter-gradle-plugin" } +// Load keystore properties from key.properties file +def keystoreProperties = new Properties() +def keystorePropertiesFile = rootProject.file('key.properties') +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) +} + android { - namespace = "com.example.marco" + // Define the namespace for your Android application + namespace = "com.marco.aiot" + // Set the compile SDK version based on Flutter's configuration compileSdk = flutter.compileSdkVersion + // Set the NDK version based on Flutter's configuration ndkVersion = flutter.ndkVersion + // Configure Java compatibility options compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } + // Configure Kotlin options for JVM target kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8 } + // Default configuration for your application defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId = "com.example.marcostage" - // You can update the following values to match your application needs. - // For more information, see: https://flutter.dev/to/review-gradle-config. + // Specify your unique Application ID. This identifies your app on Google Play. + applicationId = "com.marco.aiotstage" + // Set minimum and target SDK versions based on Flutter's configuration minSdk = flutter.minSdkVersion targetSdk = flutter.targetSdkVersion + // Set version code and name based on Flutter's configuration (from pubspec.yaml) versionCode = flutter.versionCode versionName = flutter.versionName } + // Define signing configurations for different build types + signingConfigs { + release { + // Reference the key alias from key.properties + keyAlias keystoreProperties['keyAlias'] + // Reference the key password from key.properties + keyPassword keystoreProperties['keyPassword'] + // Reference the keystore file path from key.properties + storeFile file(keystoreProperties['storeFile']) + // Reference the keystore password from key.properties + storePassword keystoreProperties['storePassword'] + } + } + + // Define different build types (e.g., debug, release) 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.debug + // Apply the 'release' signing configuration defined above to the release build + signingConfig signingConfigs.release + // Enable code minification to reduce app size + minifyEnabled true + // Enable resource shrinking to remove unused resources + shrinkResources true + // Other release specific configurations can be added here, e.g., ProGuard rules } } } +// Configure Flutter specific settings, pointing to the root of your Flutter project flutter { source = "../.." }