plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'org.jetbrains.kotlin.kapt'
    id 'androidx.navigation.safeargs'
    id 'de.undercouch.download'
}

android {
    namespace 'org.tensorflow.lite.examples.objectdetection'
    compileSdk 35

    defaultConfig {
        applicationId "org.tensorflow.lite.examples.objectdetection"
        minSdk 26
        targetSdk 33
        versionCode 1
        versionName "1.0.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        // for compiling native source
        externalNativeBuild {
            cmake {
                cppFlags ""
            }
        }

        ndk {
            abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
        }
        // --

    }

    buildFeatures {
        viewBinding true
        dataBinding true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    androidResources {
        noCompress 'tflite'
    }

    externalNativeBuild {
        cmake {
            path file('src/main/cpp/CMakeLists.txt')
        }
    }
}

// Import DownloadModels task
project.ext.ASSET_DIR = projectDir.toString() + '/src/main/assets'
project.ext.TEST_ASSETS_DIR = projectDir.toString() + '/src/androidTest/assets'

// Download default models; if you wish to use your own models then
// place them in the "assets" directory and comment out this line.
apply from: 'download_models.gradle'

dependencies {
    // Kotlin lang
    implementation 'androidx.core:core-ktx:1.15.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'

    // App compat and UI
    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.7'
    implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
    implementation 'com.google.android.material:material:1.12.0'
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
    implementation 'com.google.ai.edge.litert:litert-gpu-api:1.0.1'
    //implementation 'com.google.ai.edge.litert:litert-gpu-api:1.0.1'

    // Navigation library
    def nav_version = "2.8.5"
    implementation "androidx.navigation:navigation-fragment-ktx:2.8.5"
    implementation "androidx.navigation:navigation-ui-ktx:2.8.5"

    // CameraX core library
    def camerax_version = '1.4.1'
    implementation "androidx.camera:camera-core:$camerax_version"

    // CameraX Camera2 extensions
    implementation "androidx.camera:camera-camera2:$camerax_version"

    // CameraX Lifecycle library
    implementation "androidx.camera:camera-lifecycle:$camerax_version"

    // CameraX View class
    implementation "androidx.camera:camera-view:$camerax_version"

    // WindowManager
    implementation 'androidx.window:window:1.3.0'

    // Unit testing
    testImplementation 'androidx.test.ext:junit:1.2.1'
    testImplementation 'androidx.test:rules:1.6.1'
    testImplementation 'androidx.test:runner:1.6.2'
    testImplementation 'androidx.test.espresso:espresso-core:3.6.1'
    testImplementation 'org.robolectric:robolectric:4.10.3'

    // Instrumented testing
    androidTestImplementation "androidx.test.ext:junit:1.2.1"
    androidTestImplementation "androidx.test:core:1.6.1"
    androidTestImplementation "androidx.test:rules:1.6.1"
    androidTestImplementation "androidx.test:runner:1.6.2"
    androidTestImplementation "androidx.test.espresso:espresso-core:3.6.1"

    // TensorFlow Lite
    implementation 'org.tensorflow:tensorflow-lite:2.12.0'
    implementation 'org.tensorflow:tensorflow-lite-task-vision:0.4.0'
    implementation 'org.tensorflow:tensorflow-lite-gpu-delegate-plugin:0.4.0'
    implementation 'org.tensorflow:tensorflow-lite-gpu:2.12.0'

    implementation 'org.yaml:snakeyaml:1.29'


}
