def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new Exception("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

// 模拟器运行报错时尝试开启此项
// project.setProperty('target-platform', 'android-arm')

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 34

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_11
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        // 如打包出现Failed to transform libs.jar to match attributes
        checkReleaseBuilds false
    }

    defaultConfig {
        applicationId "com.guadou.yyemployer"
        minSdkVersion 21
        targetSdkVersion 34
        versionCode 301          //Android打包上线记得要加固并重新签名再传
        versionName "3.0.1"

        multiDexEnabled true

        ndk {
            //选择要添加的对应 cpu 类型的 .so 库。
//            abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
            abiFilters 'armeabi-v7a', 'arm64-v8a'
//            abiFilters 'armeabi-v7a'
//            abiFilters 'arm64-v8a'
        }

        manifestPlaceholders = [
                JPUSH_PKGNAME   : applicationId,
                JPUSH_APPKEY    : "1234567890",
                JPUSH_CHANNEL   : "developer-default",
                queryAllPackages: ""
        ]
    }

    //配置keystore签名
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
        debug {

        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            //默认系统混淆
            minifyEnabled true
            // 不显示Log
            buildConfigField "boolean", "LOG_DEBUG", "false"
            //是否可调试
            debuggable false
            //Zipalign优化
            zipAlignEnabled true
            //移除无用的resource文件
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            signingConfig signingConfigs.release
            //是否可调试
            debuggable true
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    implementation 'com.github.bumptech.glide:glide:4.11.0'
    kapt 'com.github.bumptech.glide:compiler:4.11.0'

    implementation 'androidx.appcompat:appcompat:1.3.1'  //加入AndroidX依赖
    implementation 'com.android.support:multidex:1.0.3'
//    implementation 'androidx.core:core-splashscreen:1.0.0' //启动12兼容
}
