build.gradle 2.74 KB
apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.xiniunet.guard3"
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    Properties props = new Properties()
    props.load(new FileInputStream(file("../app/signing.properties")))

    signingConfigs {//签名配置
        releaseConfig {//发布版签名配置
            storeFile file(props['KEYSTORE_FILE'])//密钥文件路径
            keyAlias props['KEY_ALIAS']//key别名
            storePassword props['KEYSTORE_PASSWORD']//密钥文件密码
            keyPassword props['KEY_PASSWORD']//key密码
        }
    }

    buildTypes {//build类型
        release {//发布
            debuggable false
            minifyEnabled false //启用混淆
            shrinkResources false //是否清理无用资源,依赖于minifyEnabled
            zipAlignEnabled true //是否启用zipAlign压缩
            signingConfig signingConfigs.releaseConfig//设置签名信息

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    //修改生成的apk名字,格式为 app名_版本号_打包时间_渠道名_release.apk
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def oldFile = output.outputFile
            def releaseApkName = "guard" + "_v${defaultConfig.versionName}_${releaseTime()}_" + variant.buildType.name + '.apk'
            output.outputFile = new File(oldFile.parent, releaseApkName)
        }
    }
}

/**
 * 发布时间
 * @return
 */
def releaseTime() {
    return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'

    compile 'com.youth.banner:banner:1.4.10'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile files('libs/xntalk-android-sdk-1.4.0-SNAPSHOT.jar')
    compile files('libs/xntalk-android-sdk-1.4.0-SNAPSHOT-sources.jar')
    compile 'com.yanzhenjie.nohttp:okhttp:1.1.8'
    compile 'com.alibaba:fastjson:1.1.46.android'
    compile 'com.elvishew:xlog:1.4.0'

}