plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}
def releaseTime() {
    return new Date().format("yyyyMMddHHmm", TimeZone.getTimeZone("GMT+08:00"))
}
android {

    signingConfigs {
        config {
            keyAlias 'key0'
            keyPassword '210419'
            storeFile file('gldriver.jks')
            storePassword '210419'
            v1SigningEnabled true
            v2SigningEnabled true
        }
    }



    compileSdk rootProject.ext.android["compileSdkVersion"]

    defaultConfig {
        applicationId rootProject.ext.android["applicationId"]
        minSdkVersion rootProject.ext.android["minSdkVersion"]
        targetSdkVersion rootProject.ext.android["targetSdkVersion"]
        versionCode rootProject.ext.android["versionCode"]
        versionName rootProject.ext.android["versionName"]
        flavorDimensions "CHANNEL_VALUE"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        ndk {
            //设置支持的SO库架构（开发者可以根据需要，选择一个或多个平台的so）
            abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
        debug {
            signingConfig signingConfigs.config
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '11'
    }

    buildFeatures {
        viewBinding = true
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    sourceSets {
        main {
            jniLibs.srcDir 'libs'
            //说明so的路径为该libs路径，关联所有地图SDK的so文件
        }
    }

    productFlavors {

        dev {
            applicationId "com.dahe.gldriver"
            manifestPlaceholders = [CHANNEL_VALUE: "审核端(测试)",
//                                    app_icon     : "@drawable/head_defaut",
                                    JPUSH_PKGNAME: applicationId,
                                    //JPush 上注册的包名对应的 Appkey.
                                    JPUSH_APPKEY : "5d63ef6fdf58ada352bb8f07",
                                    //暂时填写默认值即可.
                                    JPUSH_CHANNEL: "developer-n"]
            buildConfigField("String", "OPEN_AL_URL", "\"https://oapi-staging.alct56.com\"")
            buildConfigField("String", "BASE_URL", "\"http://platform.test.v2.dahehuoyun.com/devApi/\"")
            buildConfigField "boolean", "isTest", "true"
            //APP名称，可以在androidMainfest中引用
            resValue "string", "appName", "审核测试"
        }
        prod {
            applicationId "com.dahe.gldriver"
            manifestPlaceholders = [CHANNEL_VALUE: "审核端",
//                                    app_icon     : "@drawable/ysxy",
                                    JPUSH_PKGNAME: applicationId,
                                    //JPush 上注册的包名对应的 Appkey.
                                    JPUSH_APPKEY : "5d63ef6fdf58ada352bb8f07",
                                    //暂时填写默认值即可.
                                    JPUSH_CHANNEL: "developer-default"]
            buildConfigField("String", "OPEN_AL_URL", "\"https://oapi.alct56.com\"")
            buildConfigField("String", "BASE_URL", "\"http://app.dahehuoyun.com/api/\"")
            buildConfigField "boolean", "isTest", "false"
            resValue "string", "appName", "审核"
        }
    }

    android.applicationVariants.all { variant ->
        variant.outputs.all {
            //获取渠道名称
            def isText = variant.productFlavors[0].properties.get("buildConfigFields").getAt("isTest").properties.get("value")
            def appName = null
            if (isText == "true") {
                appName = '司机端测试_'
            } else {
                appName = '司机端正式_'
            }
            outputFileName = appName + "${variant.buildType.name}_${defaultConfig.versionName}_${releaseTime()}.apk"

        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.annotation:annotation:1.2.0'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'


    implementation project(path: ':mylibrary')

    //高德地图
    implementation 'com.amap.api:map2d:6.0.0'

    //定位功能
    implementation 'com.amap.api:location:6.4.2'//6.4.2
    implementation 'com.amap.api:search:9.7.0'
}