android:name="${UMENG_CHANNEL_VALUE}"
android:value="Channel_ID" />
android {
productFlavors {
xiaomi {}
yingyongbao {}
}
productFlavors.all {
flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
}
}
./gradle assembleRelease
./gradle assembleXiaomiRelease
packer-ng-plugin
美团点评技术团队:新一代开源Android渠道包生成工具Walle
apply plugin: 'com.android.application'
def releaseTime() {
return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}
android {
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(output.outputFile.parent, rootProject.getName()
+ "-" + buildType.name
+ "-" + releaseTime()
+ "-v" + defaultConfig.versionName
+ "-" + defaultConfig.versionCode
+ ".apk");
}
}
}
YFSample-release-2017-09-12-v1.0-1.apk
android {
buildTypes {
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "DEBUG_MODE", "true"
signingConfig signingConfigs.config
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "DEBUG_MODE", "false"
signingConfig signingConfigs.config
}
}
}
ReleaseKeyPassword=sampleKeyPwd
ReleaseKeyAlias=sampleAlias
ReleaseStorePassword=sampleStorePwd
ReleaseStoreFile=../sample.jks
allprojects {
afterEvaluate { project ->
def propsFile = rootProject.file('keystore.properties')
def configName = 'config'
if (propsFile.exists() && android.signingConfigs.hasProperty(configName)) {
def props = new Properties()
props.load(new FileInputStream(propsFile))
android.signingConfigs[configName].storeFile = file(props['ReleaseStoreFile'])
android.signingConfigs[configName].storePassword = props['ReleaseStorePassword']
android.signingConfigs[configName].keyAlias = props['ReleaseKeyAlias']
android.signingConfigs[configName].keyPassword = props['ReleaseKeyPassword']
}
}
}
def keystorePropertiesFile = rootProject.file("keystore.properties");
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
signingConfigs {
config {
storeFile file(keystoreProperties['ReleaseStoreFile'])
storePassword keystoreProperties['ReleaseStorePassword']
keyAlias keystoreProperties['ReleaseKeyAlias']
keyPassword keystoreProperties['ReleaseKeyPassword']
}
}
}
buildTypes {
debug {
buildConfigField "boolean", "DEBUG_MODE", "true"
}
release {
buildConfigField "boolean", "DEBUG_MODE", "false"
}
}
InfoQ — 深入理解Android(一):Gradle详解
GitBook — Gradle User Guide 中文版
极客学院 — Gradle 使用指南