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 FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

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

android {
    compileSdkVersion 28

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

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "com.tyty.liftmanager"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        ndk {
            //设置支持的SO库架构
            abiFilters 'armeabi-v7a'//, 'arm64-v8a', 'x86', 'x86_64'
        }
        manifestPlaceholders = [
                PACKAGE_NAME : applicationId,
                XG_ACCESS_ID : "2100320854",
                XG_ACCESS_KEY: "A7D99HE19CAX",
                HW_APPID     : "10839500",
                XIAOMI_APPID : "",
                XIAOMI_APPKEY: "",
                XG_ACCESS_SCHEME:"",
                JPUSH_PKGNAME : applicationId,
                JPUSH_APPKEY : "bd76ee7fb5dac9d04b12a521", // NOTE: JPush 上注册的包名对应的 Appkey.
                JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.
        ]
        multiDexEnabled true
    }
    signingConfigs {
        release {
            keyAlias 'liftmanager'
            keyPassword 'zhengmin123456'
            storeFile file('../../liftmanager.jks')
            storePassword 'zhengmin123456'
        }
    }

    buildTypes {
        release {
            ndk {
                //这里其实我觉可以直接是用"armeabi-v7a"，但国内几个大哥之前使用的都是"armeabi"
                abiFilters "armeabi"
//                abiFilters "armeabi-v7a"
            }
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.release
        }
        debug {
            ndk {
                //这里要加上，否则debug包会出问题,后面三个为可选，x86建议加上不然部分模拟器回报错
                abiFilters "armeabi", "armeabi-v7a","arm64-v8a", "x86"
//                signingConfig signingConfigs.release
            }
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

    implementation project(":libs")
}
