buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:8.0.2") // Android Gradle Plugin
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10") // Kotlin Gradle Plugin
    }
}

plugins {
    id 'com.android.library' // For building an Android library
    id 'kotlin-android'      // For Kotlin compatibility
}

android {
    namespace 'com.useideem.zsm.reactnative' // Define the package name
    compileSdk 35 // Set the compile SDK version

    defaultConfig {
        minSdk 26 // Minimum SDK version
        targetSdk 35 // Target SDK version

        // Required for Kotlin and Java compatibility
        multiDexEnabled true
    }

    sourceSets {
        main {
            java.srcDirs = ['src/main/java']
            manifest.srcFile 'src/main/AndroidManifest.xml'
        }
    }

    buildTypes {
        release {
            minifyEnabled false // Disable minification for easier debugging
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17 // Updated to match latest LTS Java version
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = '17' // Align Kotlin JVM target with Java version
    }
}

repositories {
    google()
    mavenCentral()
    maven { url 'https://oss.sonatype.org/content/groups/public/' } // React Native repository
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.aar"]) // Include ZSM.aar library

    // React Native dependency - specify version to avoid resolution issues
    implementation 'com.facebook.react:react-native:+'

    // Basic Android dependencies
    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'androidx.core:core-ktx:1.13.1'

    // Optional: Kotlin Standard Library
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.10"

    // MultiDex support (required for larger projects)
    implementation 'androidx.multidex:multidex:2.0.1'
}
