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')
}