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

android {
    namespace = "com.lxh.battery_health"
    compileSdk = flutter.compileSdkVersion
    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 = flutter.targetSdkVersion
        versionCode = flutter.versionCode
        versionName = flutter.versionName
        multiDexEnabled = true
    }

    signingConfigs {
        create("release") {
            // 这里配置你正式发布的签名
            // 如果还没有正式签名，debug 可以用 debug 签名替代
            keyAlias = "your_key_alias"
            keyPassword = "your_key_password"
            storeFile = file("your_keystore.jks")
            storePassword = "your_store_password"
        }
    }

    signingConfigs {
        // 如果没有正式签名，可以暂时用 debug 签名
        // 正式发布时再替换
    }

    buildTypes {
        debug {
            applicationIdSuffix = ".dev"
            signingConfig = signingConfigs.getByName("debug")
        }

        release {
            applicationIdSuffix = ""  // 保持原包名
            // 🟢 如果还没有正式签名，先用 debug 签名替代
            signingConfig = signingConfigs.getByName("debug")
            isMinifyEnabled = true
            isShrinkResources = true
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }

    // 如果有 productFlavors，可以在这里配置
    // 如果没有，忽略即可
    }

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

dependencies {
    // 如果项目中有其他依赖，添加在这里
    // 注意：sqflite、permission_handler 等 Flutter 插件会自动包含
}