apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply from: 'tinker-support.gradle'
android {
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
        disable 'InvalidPackage'
    }

    compileSdkVersion 25
    buildToolsVersion '25.0.2'

    defaultConfig {
        applicationId "info.meizi_retrofit"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 20170822
        versionName "1.8.5"
        resConfigs "zh"//只要中文的第二三方包等
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def outputFile = output.outputFile
            if (outputFile != null && outputFile.name.endsWith('.apk')) {
                // 输出apk名称为Meizi_v1.0_wandoujia.apk
                def fileName = "Meizi_v${defaultConfig.versionName}.apk"
                output.outputFile = new File(outputFile.parent, fileName)
            }
        }
    }
    signingConfigs {
        debug {

        }
        release {
            File propFile = file('sign.properties');
            if (propFile.exists()) {
                println("文件存在")
                def Properties props = new Properties()
                props.load(new FileInputStream(propFile))
                if (props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
                        props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
                    storeFile file(props['STORE_FILE'])
                    storePassword props['STORE_PASSWORD']
                    keyAlias props['KEY_ALIAS']
                    keyPassword props['KEY_PASSWORD']
                }
            } else {
                println("文件不存在")
            }
        }
    }

    buildTypes {
        debug {
            buildConfigField "boolean", "LOG_DEBUG", "true"

            File propFile = file('sign.properties');
            def Properties props = new Properties()
            props.load(new FileInputStream(propFile))
            buildConfigField "String", "APPLICATIONID", props['APPLICATIONID']
            buildConfigField "String", "CLIENTKEY", props['CLIENTKEY']

            debuggable true
            minifyEnabled false
            zipAlignEnabled false
            shrinkResources false
            signingConfig signingConfigs.debug
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'//混淆文件
        }
        release {
            // 不显示Log
            buildConfigField "boolean", "LOG_DEBUG", "false"

            File propFile = file('sign.properties');
            def Properties props = new Properties()
            props.load(new FileInputStream(propFile))
            buildConfigField "String", "APPLICATIONID", props['APPLICATIONID']
            buildConfigField "String", "CLIENTKEY", props['CLIENTKEY']


            debuggable false
            minifyEnabled true//混淆
            zipAlignEnabled true//优化
            shrinkResources true//去除无用资源
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'//混淆文件
            signingConfig signingConfigs.release//使用这个闭包进行签名

        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:palette-v7:25.3.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
    compile 'io.reactivex:rxandroid:1.0.1'
    compile 'io.reactivex:rxjava:1.0.14'
    compile 'io.reactivex:rxjava-math:1.0.0'
    compile 'com.jakewharton.rxbinding:rxbinding:0.2.0'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.3.0'
    compile 'org.jsoup:jsoup:1.8.2'
    compile files('libs/butterknife-7.0.1.jar')
    compile 'com.github.zhaokaiqiang.klog:library:1.3.0'
    compile 'me.gujun.android.taggroup:library:1.4@aar'
    compile 'com.squareup:otto:1.3.8'
    compile('cn.leancloud.android:avoscloud-sdk:v4.4.4')

    compile "com.android.support:multidex:1.0.1"

    compile 'com.tencent.bugly:crashreport_upgrade:1.3.0'
}
