// 添加插件

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 GradleException("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'
}

// 获取当前时间(年月日)
def releaseTime() {
    return new Date().format("YYYYMMdd", TimeZone.getTimeZone("UTC"))
}

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


android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    // 默认配置
    defaultConfig {
        applicationId "cn.zhios.zhiying"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        aaptOptions.cruncherEnabled = false
        aaptOptions.useNewCruncher = false
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        ndk {
            //选择要添加的对应cpu类型的.so库。
            abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a'
        }
    }

    // 签名配置
    signingConfigs {
        // 智夜生活
        zhiying {
            storeFile file('zhiying.jks')
            storePassword 'zhioscom'
            keyAlias 'zysh'
            keyPassword 'zhioscom'
            v1SigningEnabled true
            v2SigningEnabled true
        }

    }

    flavorDimensions "app"

    buildTypes {
        debug {
            buildConfigField "boolean", "LOG_DEBUG", "true"
            minifyEnabled false
            zipAlignEnabled true
            shrinkResources false
            signingConfig signingConfigs.zhiying
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            buildConfigField "boolean", "LOG_DEBUG", "false"
            minifyEnabled false
            shrinkResources false
            zipAlignEnabled true
            signingConfig signingConfigs.zhiying
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    dexOptions {
        //最大堆内存
        javaMaxHeapSize "4g"//4g
        //使用增量模式构建
        incremental true
        //是否支持大工程模式
        jumboMode = true
        //预编译
        preDexLibraries = false
        //线程数
        threadCount = 8
    }


    // 应用信息配置
//    productFlavors {
//        // 智夜生活
//        zhiying {
//            applicationId "cn.zhios.zhiying"
//            versionCode 34
//            dimension "app"
//            versionName '1.2.34'
//            // 签名信息
//            signingConfig signingConfigs.zhiying
//        }
//    }
//
//    // 打包脚本
//    android.applicationVariants.all { variant ->
//        if (variant.buildType.name != "debug") {
//            variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk")
//        }
//
//        variant.outputs.all { output ->
//            def outputFile = output.outputFile
//            if (outputFile != null && outputFile.name.endsWith('.apk')) {
//                //这里修改apk文件名
//                def fileName = "${variant.productFlavors[0].name}_${releaseTime()}01_&V${variant.productFlavors[0].versionCode}.apk"
//                outputFileName = fileName
//            }
//        }
//    }

    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.android.support') {
                if (!requested.name.startsWith("multidex")) {
                    details.useVersion '28.0.3'
                }
            }
            resolutionStrategy.force 'com.android.support:support-v4:28.0.0'
        }
    }


}

flutter {
    source '../..'
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

//登陆
    implementation 'com.ali.auth.sdk:alibabauth_core:2.0.0.11@aar'
    implementation 'com.ali.auth.sdk:alibabauth_ui:2.0.0.11@aar'
    implementation 'com.ali.auth.sdk:alibabauth_ext:2.0.0.11@aar'
    //安全组件
    implementation 'com.taobao.android:securityguardaar3:5.4.171@aar'
    implementation 'com.taobao.android:securitybodyaar3:5.4.99@aar'
    implementation 'com.taobao.android:avmpaar3:5.4.36@aar'
    implementation 'com.taobao.android:sgmiddletieraar3:5.4.9@aar'
    //Mtop
    implementation 'com.taobao.android:mtopsdk_allinone_open:3.1.2.5@jar'
    //applink
    implementation 'com.alibaba.sdk.android:alibc_link_partner:4.1.15@aar'
    //ut
    implementation 'com.taobao.android:utdid4all:1.5.2'
    implementation 'com.alibaba.mtl:app-monitor-sdk:2.6.4.5_for_bc'
    // 电商基础组件
    implementation 'com.alibaba.sdk.android:AlibcTradeCommon:4.0.0.16@aar'
    implementation 'com.alibaba.sdk.android:AlibcTradeBiz:4.0.0.16@aar'
    implementation 'com.alibaba.sdk.android:nb_trade:4.0.0.16@aar'
    implementation 'com.alibaba:fastjson:1.2.41@jar'
}


MobSDK {
    appKey "30dc33054b635"
    appSecret "396e98c293130c9976fb7428b6b434d6"

    MobLink {
        uriScheme "fnoos://cn.zhios.zhiying"
        appLinkHost "bied.t4m.cn"
    }

    //手机验证登录
    SecVerify {}

    //短信
    SMSSDK {}

    ShareSDK {

        // platform configuration information
        devInfo {
            QQ {
                appId "1111030588"
                appKey "XoHKlrBybXy7ORBt"
                shareByAppClient true
                bypassApproval false
                enable true
            }
            Wechat {
                appId "wx598aaef252cd78e4"
                appSecret "d2fc2edf9ece746765b3bfc0bf1b230e"
                shareByAppClient true
                withShareTicket true
                bypassApproval false
                enable true
            }
            WechatMoments {
                enable true
            }
            WechatFavorite {
                enable true
            }
            QZone {
                enable true
            }
            SinaWeibo {
                enable true
            }
        }
    }

    //配置MobPush
    MobPush {
        //配置厂商推送(可选配置,不需要厂商推送可不配置,需要哪些厂商推送只需配置哪些厂商配置即可)
        devInfo {
            //配置小米厂商推送
            XIAOMI {
                appId "您的小米平台appId"
                appKey "您的小米平台appKey"
            }

            //配置华为厂商推送
            HUAWEI {
                appId "您的华为平台appId"
            }

            //配置魅族厂商推送
            MEIZU {
                appId "您的魅族平台appId"
                appKey "您的魅族平台appKey"
            }

//            //配置FCM厂商推送
//            FCM {
//                //设置默认推送通知显示图标
//                iconRes "@mipmap/default_ic_launcher"
//            }

            //配置OPPO厂商推送
            OPPO {
                appKey "您的OPPO平台appKey"
                appSecret "您的OPPO平台appSecret"
            }

            //配置VIVO厂商推送
            VIVO {
                appId "您的VIVO平台appId"
                appKey "您的VIVO平台appKey"
            }
        }
    }
}

// 注册SecVerify的相关信息
//MobSDK {
////    appKey "2ed488d929488"
////    appSecret "53d4a16298d283828f2444cdd6d6548a"
//    //手机验证登录
//    SecVerify {}
//
//    //短信
//    SMSSDK {}
//
//    //调用MobPush,推送
////    MobPush {
////        //设置角标开关(不需要可不设置)
//////        badge true
////        //集成其他推送通道(可选)
////        devInfo {
////            //华为推送配置信息
////            HUAWEI {
////                appId "${HUAWEI_PUSH_ID}"
////            }
////            //魅族推送配置信息
////            MEIZU {
////                appId "${MEIZHU_PUSH_APPID}"
////                appKey "${MEIZHU_PUSH_APPKEY}"
////            }
////            //小米推送配置信息
////            XIAOMI {
////                appId "${XIAOMI_PUSH_APPID}"
////                appKey "${XIAOMI_PUSH_APPKEY}"
////            }
////            //FCM推送通道配置
//////            FCM {
////            //设置默认推送通知显示图标
//////                iconRes "@mipmap/ic_launcher"
//////            }
////            //OPPO推送配置信息
////            OPPO {
////                appKey "${OPPO_PUSH_APPKEY}"
////                appSecret "${OPPO_PUSH_APPSECRET}"
////            }
////            //VIVO推送配置信息
////            VIVO {
////                appId "${VIVO_PUSH_APPID}"
////                appKey "${VIVO_PUSH_APPKEY}"
////            }
////        }
////    }
//
//    //分享
//    ShareSDK {
//        loopShare true
//        devInfo {
//            SinaWeibo {
//                enable true
//            }
//            Wechat {
////                appId "${Wechat_appid}"
////                appSecret "${Wechat_appSecret}"
//                enable true
//                withShareTicket true
//                bypassApproval false
//            }
//            QQ {
//                enable true
//            }
//            WechatMoments {
//                enable true
//            }
//            WechatFavorite {
//                enable true
//            }
//            QZone {
//                enable true
//            }
//        }
//    }
//
//    //网页打开app,接受邀请码
//    MobLink {
////        uriScheme "${uri_Scheme}"
////        appLinkHost "${app_LinkHost}"
//    }
//}