build.gradle记录


apply plugin: 'com.android.application'

def inputParm = project.hasProperty("oem") ? oem : "";
def signFile = "${rootDir}/hisi.keystore";
if (inputParm.equalsIgnoreCase("ABC")) {
    signFile = "${rootDir}/mstar.keystore"
} else if (inputParm.equalsIgnoreCase("DEV")) {
    signFile = "${rootDir}/rk.keystore"
}

//指定oem编译
//gradlew assembleABCDebug -Poem=ABC
//gradlew assembleDEFRelease -Poem=DEV
//一次编译所有oem release版本
//gradlew assembleRelease

android {

    compileSdkVersion 25
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "com.test.hello"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 6
        versionName buildVersionName()

        buildConfigField "int", "oem", "0"
        buildConfigField "int", "type", "0"
        buildConfigField "String", "path", "\"abc123\""
    }

    productFlavors {
        ABC {
            buildConfigField "int", "oem", "0"
        }
        DEF {
            buildConfigField "int", "oem", "1"
            buildConfigField "int", "type", "1"
        }
    }

    applicationVariants.all { variant ->
        // each遍历variant
        variant.outputs.each { output ->
            def outputFile = output.outputFile
            if (outputFile != null) {
                def fileName;
                if (outputFile.name.endsWith('release.apk')) {
                    fileName = "${variant.productFlavors[0].name}_${defaultConfig.versionName}_release.apk";
                    output.outputFile = new File("myoutputs", fileName);
                } else if (outputFile.name.endsWith('debug.apk')) {
                    fileName = "${variant.productFlavors[0].name}_${defaultConfig.versionName}_debug.apk";
                    output.outputFile = new File("myoutputs", fileName);
                }
            }
        }
    }

    lintOptions {
        ignoreWarnings true
        checkReleaseBuilds false
        abortOnError false
    }

    signingConfigs {
        debug {
            storeFile file(signFile)
            storePassword "12345678"
            keyAlias "android"
            keyPassword "123456"
        }
        release {
            storeFile file(signFile)
            storePassword "12345678"
            keyAlias "android"
            keyPassword "123456"
        }
    }

    buildTypes {
        debug {
            jniDebuggable = true
            minifyEnabled false
            zipAlignEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            //signingConfig signingConfigs.release
        }
        release {
            // 如果没有提供混淆规则文件,则设置默认的混淆规则文件(SDK/tools/proguard/proguard-android.txt)
            pseudoLocalesEnabled true
            //混淆
            minifyEnabled true
            //Zipalign优化
            zipAlignEnabled true
            // 移除无用的resource文件
            shrinkResources true
            //加载默认混淆配置文件
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'//混淆文件
            //签名
            signingConfig signingConfigs.release
        }
    }
}

def buildVersionName() {
    def date = new Date();
    def ver = date.format("YYYYMMdd")
    return ver + "_V1.2"
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:multidex:1.0.0'
    compile files('libs/okhttp-3.2.0.jar')
    compile files('libs/okio-1.8.0.jar')
    compile files('libs/ThinDownloadManager-1.2.5.jar')
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

LakeSideHu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值