plugins {
    id "com.android.application"
    id "org.jetbrains.kotlin.android" version "2.1.0"
    id "com.google.gms.google-services"
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}


def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
    namespace "com.camelsoft.muaawana"
    compileSdkVersion 36
    ndkVersion flutter.ndkVersion

    packagingOptions {
        pickFirst 'lib/arm64-v8a/libc++_shared.so'

        jniLibs {
            useLegacyPackaging = true
        }
    }
    compileOptions {
        coreLibraryDesugaringEnabled true
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = '17'
    }
    defaultConfig {
        applicationId "com.camelsoft.muaawana"
        minSdkVersion 28
        multiDexEnabled true
        // Google Play requires targetSdk 36 (Android 16) for new uploads;
        // an app targeting 35 is rejected at release creation.
        targetSdk 36
        versionCode = flutter.versionCode
        versionName = flutter.versionName
        ndk {
            abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
        }
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    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.release
        }
    }
}

flutter {
    source = "../.."
}
dependencies {
    implementation platform('com.google.firebase:firebase-bom:32.7.1')
    implementation 'com.google.firebase:firebase-messaging:23.4.1'
    implementation "com.google.firebase:firebase-core:21.1.1"
    implementation 'com.google.android.gms:play-services-maps:18.1.0'
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4'
    implementation 'androidx.window:window:1.2.0'
    implementation 'androidx.window:window-java:1.2.0'
    implementation 'com.facebook.android:facebook-android-sdk:18.0.0'
    implementation 'androidx.annotation:annotation:1.3.0'
    implementation 'org.microg:safe-parcel:1.7.1'
    implementation 'androidx.multidex:multidex:2.0.1'

}