plugins {
    id("com.android.application")
    id("kotlin-android")
    id("dev.flutter.flutter-gradle-plugin")
}

android {
    namespace = "com.lxh.battery_health"
    compileSdk = 34
    ndkVersion = flutter.ndkVersion

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

    kotlinOptions {
        jvmTarget = "17"
    }

    defaultConfig {
        applicationId = "com.lxh.battery_health"
        minSdk = flutter.minSdkVersion
        targetSdk = 34
        versionCode = flutter.versionCode
        versionName = flutter.versionName
        multiDexEnabled = true
    }

    signingConfigs {
        // 如果没有正式签名，可以用 debug 签名代替（测试用）
        // 正式发布时请替换为自己的密钥
        getByName("debug") {
            // debug 签名已经存在，无需额外配置
        }
        create("release") {
            // 如果有正式签名，在这里配置
            // keyAlias = "..."
            // keyPassword = "..."
            // storeFile = file("...")
            // storePassword = "..."
        }
    }

    buildTypes {
        debug {
            // 🟢 关键：debug 版本包名加 .dev 后缀
            applicationIdSuffix = ".dev"
            signingConfig = signingConfigs.getByName("debug")
            isDebuggable = true
            isMinifyEnabled = false
            isShrinkResources = false
        }
        release {
            // release 版本不加后缀，保持原包名
            signingConfig = signingConfigs.getByName("debug") // 若没有正式签名，先用 debug 签名
            isMinifyEnabled = true
            isShrinkResources = true
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
}

flutter {
    source = "../.."
}

dependencies {
    // 无需额外添加 Activity KTX，因为已改用 startActivityForResult
}
