plugins {
    id "com.android.application"
    // START: FlutterFire Configuration
    id 'com.google.gms.google-services'
    // END: FlutterFire Configuration
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
// Load keystore properties if the file exists
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    namespace = "com.intaleq_driver"
    compileSdk = 36
    ndkVersion "29.0.14033849"

    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            // Using a common, stable version. Your CMakeLists.txt requests 3.10.2, 
            // but your old gradle file had 3.22.1 and 3.31.5. Let's use a stable one.
            version "3.22.1" 
        }
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
        coreLibraryDesugaringEnabled true
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }

    // Merged the two defaultConfig sections into one. This is the correct way.
    defaultConfig {
        applicationId = "com.intaleq_driver"
        minSdkVersion = 23
        targetSdk = 36
        versionCode = 47
        versionName = '1.0.47' // I've used the higher version name
        multiDexEnabled = true

        ndk {
            abiFilters "armeabi-v7a", "arm64-v8a"  // Keep these!
        }
    }

    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }

   buildTypes {
       release {
           signingConfig signingConfigs.release
           minifyEnabled true
           shrinkResources true
           proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
       }
   }
}

flutter {
    source = "../.."
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.scottyab:rootbeer-lib:0.1.0'
    implementation 'com.stripe:paymentsheet:20.52.2'
    implementation "androidx.concurrent:concurrent-futures:1.2.0" // Added this from your first file, it was missing
    implementation 'com.google.android.gms:play-services-safetynet:18.0.1'
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4'
}
