plugins {
    id "com.android.application"
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

android {
    namespace = "com.trace.location"
    compileSdk = rootProject.ext.compileSdkVersion
    ndkVersion = flutter.ndkVersion

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

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }

    configurations.configureEach {
        resolutionStrategy {
            // don't cache changing modules at all
            cacheChangingModulesFor 10, 'seconds'
        }
    }

    defaultConfig {
        applicationId = rootProject.ext.applicationId
        minSdk = rootProject.ext.minSdkVersion
        targetSdk = rootProject.ext.targetSdkVersion
        versionCode = flutter.versionCode
        versionName = flutter.versionName

        ndk {
            //noinspection ChromeOsAbiSupport
            abiFilters "arm64-v8a"
        }
    }

    signingConfigs {
        location {
            storeFile file("keystore/location.jks")
            storePassword "location888"
            keyAlias "location"
            keyPassword "location888"
        }
    }


    buildTypes {
        debug {
            // Note: The debug build type must have the same signing config as the main build type.
            signingConfig signingConfigs.location
        }
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.location
        }
    }

    applicationVariants.configureEach { variant ->
        def date = new Date().format("YYMMddHHmmss")
        variant.outputs.configureEach {
            def fileName = "${defaultConfig.applicationId}" +
                    "-v${defaultConfig.versionName}" +
                    "-${variant.buildType.name}" +
                    "-${date}" +
                    ".apk"
            outputFileName = fileName
        }
    }
}

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