build.gradle的内容

在网上找的一些知识点;地址:http://stormzhang.com/devtools/2014/12/18/android-studio-tutorial4/

以便自己以后理解使用:

//声明是Android程序
apply plugin: 'com.android.application'

apply plugin: 'me.tatarka.retrolambda'

//获取当前时间
def releaseTime() {
    return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}

android {
    //签名
    signingConfigs {
        debug{
            //debug模式
        }

        release {
            keyAlias 'lambda'
            keyPassword '940219'
            storeFile file('D:/lambda.jks')
            storePassword '940219'
        }
    }
    //编译SDK的版本
    compileSdkVersion 25
    //build tools的版本
    buildToolsVersion "25.0.1"
    defaultConfig {
        //应用的包名
        applicationId "hwelltech.com.lambdademo01"
        //SDK最低版本
        minSdkVersion 24
        //目标SDK版本
        targetSdkVersion 25
        //代码版本
        versionCode 1
        //版本名字
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    //java版本
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {

        debug{
            //debug模式
            // 显示Log
            buildConfigField "boolean", "LOG_DEBUG", "true"

            versionNameSuffix "-debug"
            minifyEnabled false
            zipAlignEnabled false
            shrinkResources false
            signingConfig signingConfigs.debug
        }

        release {
            // 不显示Log
            buildConfigField "boolean", "LOG_DEBUG", "false"

            zipAlignEnabled true
            // 移除无用的resource文件
            shrinkResources false
            //是否进行混淆
            minifyEnabled false
            //混淆文件的位置
            //第一个文件位置**/tools/proguard/proguard-android.txt**
            //第二个文件位置**app/proguard-rules.txt**
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            //签名
            signingConfig signingConfigs.release

            applicationVariants.all { variant ->
                variant.outputs.each { output ->
                    def outputFile = output.outputFile
                    if (outputFile != null && outputFile.name.endsWith('.apk')) {
                        // 输出apk名称为lambda1.0_2015-01-15_wandoujia.apk
                        def fileName = "lambda_${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}.apk"
                        output.outputFile = new File(outputFile.parent, fileName)
                    }
                }
            }
        }
    }

    // 移除lint检查的error
    lintOptions {
        abortOnError false
    }


    // 友盟多渠道打包
    productFlavors {
        wandoujia {}
        _360 {}
        baidu {}
        xiaomi {}
        tencent {}
        taobao {}
    }

    productFlavors.all { flavor ->
        flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
    }

    /**
     * 或者这个
     * android {
     productFlavors {
     xiaomi {
     manifestPlaceholders = [UMENG_CHANNEL_VALUE: "xiaomi"]
     }
     _360 {
     manifestPlaceholders = [UMENG_CHANNEL_VALUE: "_360"]
     }
     baidu {
     manifestPlaceholders = [UMENG_CHANNEL_VALUE: "baidu"]
     }
     wandoujia {
     manifestPlaceholders = [UMENG_CHANNEL_VALUE: "wandoujia"]
     }
     }
     }
     */


}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    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.1.0'
    testCompile 'junit:junit:4.12'
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值