import java.text.SimpleDateFormat
import java.util.Locale

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
    id("com.google.gms.google-services")
    id("com.google.firebase.crashlytics")
//    id("com.google.devtools.ksp")
    id("org.jetbrains.kotlin.kapt")
}

android {
    namespace = "com.dumpster.cleaner"
    compileSdk = 35

    defaultConfig {
        applicationId = "com.link.play.fit.ai.test1"// "com.link.play.fit.ai.test1"
        minSdk = 24
        targetSdk = 35
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

        fun Long.toFormatTime3(): String {
            return SimpleDateFormat("yyyy-MM-dd-HH", Locale.ENGLISH).format(this)
        }
        setProperty("archivesBaseName", "dumpster_cleaner-v$versionName($versionCode)-${System.currentTimeMillis().toFormatTime3()}")

        ndk {
            // 设置支持的 ABI 架构
            abiFilters.add("x86")
            abiFilters.add("x86_64")
            abiFilters.add("armeabi-v7a")
            abiFilters.add("arm64-v8a")//最常用
        }
    }
    signingConfigs {
        getByName("debug") {
            storeFile = file("../debug-release-key.keystore")
            storePassword = "123456"
            keyPassword = "123456"
            keyAlias = "my_alias"
            enableV1Signing = true
            enableV2Signing = true
            enableV3Signing = true
        }
        create("release") {
            storeFile = file("../debug-release-key.keystore")
            storePassword = "123456"
            keyPassword = "123456"
            keyAlias = "my_alias"
            enableV1Signing = true
            enableV2Signing = true
            enableV3Signing = true
        }
    }

    buildTypes {
        release {
            isMinifyEnabled = true
            isDebuggable = false
            isShrinkResources = true
            isJniDebuggable = false

            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
            signingConfig = signingConfigs.getByName("release")
        }
        debug {
            // applicationIdSuffix = ".debug"
            isMinifyEnabled = false
            isDebuggable = true
            isShrinkResources = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
            signingConfig = signingConfigs.getByName("debug")
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }

    buildFeatures {
        viewBinding = true
        buildConfig = true
    }
//    splits {
//        abi {
//            isEnable = true  // 启用 ABI 分包
//            reset()  // 清空默认列表
//            include("x86", "x86_64", "armeabi-v7a", "arm64-v8a")  // 指定包含的 ABI
//            isUniversalApk = true  // 是否生成通用 APK（包含所有 ABI）
//        }
//    }

}

gradle.taskGraph.whenReady {
    tasks.forEach { task ->
        if (task.name.contains("uploadCrashlyticsMappingFile")) {
            task.enabled = false
        }
    }
}

dependencies {

    implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))

    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.appcompat)
    implementation(libs.material)
    implementation(libs.androidx.activity)
    implementation(libs.androidx.constraintlayout)
    implementation(libs.androidx.navigation.fragment.ktx)
    implementation(libs.androidx.navigation.ui.ktx)
    testImplementation(libs.junit)
    androidTestImplementation(libs.androidx.junit)
    androidTestImplementation(libs.androidx.espresso.core)

    // 语种切换框架：https://github.com/getActivity/MultiLanguages
    implementation("com.github.getActivity:MultiLanguages:9.3")


    //网络
    implementation("com.squareup.okhttp3:okhttp:4.9.0")
    implementation("com.squareup.okhttp3:logging-interceptor:4.9.0")
    implementation("com.google.code.gson:gson:2.10.1")

    //第三方UI控件
    implementation("io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.4")
    implementation("com.github.angcyo.DslTablayout:TabLayout:3.7.1")
    //lottie
    implementation("com.airbnb.android:lottie:6.4.0")
    implementation("com.github.bumptech.glide:glide:4.16.0")
//    annotationProcessor("com.github.bumptech.glide:compiler:4.16.0")
    kapt("com.github.bumptech.glide:compiler:4.16.0")
    implementation("jp.wasabeef:glide-transformations:4.3.0")
    implementation("com.github.pokercc:ExpandableRecyclerView:0.9.3")
    implementation("com.mikhaellopez:circularprogressbar:3.1.0")

    //可选
//    implementation("com.github.angcyo.DslTablayout:ViewPager1Delegate:3.7.1")
    //可选
    implementation("com.github.angcyo.DslTablayout:ViewPager2Delegate:3.7.1")
    implementation("io.supercharge:shimmerlayout:2.1.0")

    //solar 归因
    implementation("com.reyun.solar.engine.oversea:solar-engine-core:1.2.8.3")
    //facebook
    implementation("com.facebook.android:facebook-android-sdk:[8,9)")

    //firebase
    implementation(platform("com.google.firebase:firebase-bom:32.3.1"))
    implementation("com.google.firebase:firebase-messaging")
    implementation("com.google.firebase:firebase-analytics-ktx")
    implementation("com.google.firebase:firebase-crashlytics")
    implementation("com.google.firebase:firebase-config")

    //广告
    //admob渠道
    implementation(libs.vungle)
    implementation(libs.facebook)
    implementation(libs.mintegral)
    implementation(libs.pangle)
    //applovin sdk
    implementation(libs.applovin)
    //applovin渠道
    implementation(libs.applovin.google)
    implementation(libs.applovin.admob)
    implementation(libs.applovin.facebook) //meta
    implementation(libs.applovin.mintegral)//mintegral
    implementation(libs.applovin.pangle) //pangle
    implementation(libs.applovin.vungle) //vungle

    val work_version = "2.8.1"
    implementation("androidx.work:work-runtime-ktx:$work_version")

    val billing_version = "7.1.1"
    implementation("com.android.billingclient:billing:$billing_version")
    implementation("com.android.billingclient:billing-ktx:$billing_version")


}