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

if (file("google-services.json").exists()) {
    apply(plugin = "com.google.gms.google-services")
}

android {
    namespace = "com.sehatsahoolat.sehat_sahoolat"
    // Override Flutter's default compileSdk — connectivity_plus requires 36+,
    // agora_rtc_engine requires 33+, androidx.fragment 1.7.1 requires 34+.
    // 36 satisfies all of them. minSdk stays at Flutter's default so we don't
    // drop support for older devices.
    compileSdk = 36
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
        // Required by flutter_local_notifications 19.x — it uses
        // java.time APIs that only exist on API 26+, so on older devices
        // they need to be desugared.
        isCoreLibraryDesugaringEnabled = true
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.sehatsahoolat.sehat_sahoolat"
        // You can update the following values to match your application needs.
        // For more information, see: https://flutter.dev/to/review-gradle-config.
        minSdk = flutter.minSdkVersion
        targetSdk = flutter.targetSdkVersion
        versionCode = flutter.versionCode
        versionName = flutter.versionName
    }

    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")
        }
    }
}

kotlin {
    compilerOptions {
        jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
    }
}

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

dependencies {
    // The desugar_jdk_libs runtime that backports java.time + java.nio etc.
    // for older Android devices when isCoreLibraryDesugaringEnabled is on.
    coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
}
