plugins {
    alias(libs.plugins.android.application)
}

android {
    namespace = "com.example.generator"
    compileSdk = 36

    defaultConfig {
        applicationId = "com.example.generator"
        minSdk = 23
        targetSdk = 34
        versionCode = 5
        versionName = "2.3"
        multiDexEnabled = true // Required since you added the multidex dependency

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }

    compileOptions {
        isCoreLibraryDesugaringEnabled = true
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    packaging {
        resources {
            excludes += "META-INF/DEPENDENCIES"
            excludes += "META-INF/INDEX.LIST"
            // CRITICAL: WPILib libraries include desktop JNI files.
            // This prevents duplicate file and incompatible native architecture errors.
            excludes += "**/libntcore.dylib"
            excludes += "**/ntcore.dll"
            excludes += "**/libntcore.so"
            excludes += "**/libwpiutil.dylib"
            excludes += "**/wpiutil.dll"
            excludes += "**/libwpiutil.so"
        }
    }
}


dependencies {
    // Desugaring & MultiDex
    coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
    implementation("androidx.multidex:multidex:2.0.1")

    // Core Android UI
    implementation(libs.activity.ktx)
    implementation(libs.appcompat)
    implementation(libs.material)
    implementation(libs.activity)
    implementation(libs.constraintlayout)

    // Google Sheets & Core API
    implementation("com.google.apis:google-api-services-sheets:v4-rev581-1.25.0") {
        exclude(group = "com.google.guava", module = "listenablefuture")
    }
    implementation("com.google.api-client:google-api-client:1.32.1")
    implementation("com.google.oauth-client:google-oauth-client:1.32.1")
    implementation("com.google.http-client:google-http-client-gson:1.42.3")
    implementation("com.google.auth:google-auth-library-oauth2-http:1.15.0")

    // JSON & Networking
    implementation("com.google.code.gson:gson:2.10.1")
    implementation("com.fasterxml.jackson.core:jackson-databind:2.15.2")
    implementation("com.squareup.okhttp3:okhttp:4.12.0")

    // Testing
    testImplementation(libs.junit)
    androidTestImplementation(libs.ext.junit)
    androidTestImplementation(libs.espresso.core)
}
