gradle打包分测试、开发、生产环境
buildTypes {
debug {
signingConfig signingConfigs.myConfig
buildConfigField("boolean", "isDebug", "true")
}
release {
signingConfig signingConfigs.myConfig//不要忘了要在release的时候加入我么的签名配置信息
minifyEnabled true
buildConfigField("boolean", "isDebug", "false")
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
//创建两个维度的 flavor
flavorDimensions "channel", "server"
productFlavors {
xuehu { dimension "channel" }
// yybao { dimension "channel" }
// wandoujia {}
// baidu {}
// c360 {}
// uc {}
// xiaomi {}
// lenovo {}
// samsung {}
// dev10086 {}
// open189 {}
// wo {}
// huawei {}
// oppo {}
// vivo {}
// flyme {}
// gionee {}
dev {
dimension "server"
buildConfigField("String", "APP_URL", '"https://dev.app.xuehu365.com/"')
buildConfigField("String", "WAP_URL", '"https:/m.dev.app.xuehu365.com/"')
buildConfigField("String", "H5_URL", '"https://dev.s.xuehu365.com/"')
buildConfigField("boolean", "isEncode", "false")
buildConfigField("boolean", "isOpenUmeng", "false")
buildConfigField("String", "APPId", '"test"')
buildConfigField("String", "JPushAlias", '"dev_"')
buildConfigField("String", "JPushTags", '"dev"')
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
output.outputFile = new File(file.parent, file.name.replace(file.name,
variant.productFlavors[0].name + "_" +
variant.versionName
+ "_dev.apk"))
}
}
}
detect {
dimension "server"
buildConfigField("String", "APP_URL", '"https://test-app.xuehu365.com/"')
buildConfigField("String", "WAP_URL", '"https://test-m.xuehu365.com/"')
buildConfigField("String", "H5_URL", '"https://test-s.xuehu365.com/"')
buildConfigField("boolean", "isEncode", "false")
buildConfigField("boolean", "isOpenUmeng", "false")
buildConfigField("String", "APPId", '"test"')
buildConfigField("String", "JPushAlias", '"test_"')
buildConfigField("String", "JPushTags", '"test"')
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
output.outputFile = new File(file.parent, file.name.replace(file.name,
variant.productFlavors[0].name + "_" +
variant.versionName
+ "_test.apk"))
}
}
}
prod {
dimension "server"
buildConfigField("String", "APP_URL", '"https://app.xuehu365.com/"')
buildConfigField("String", "WAP_URL", '"https://m.xuehu365.com/"')
buildConfigField("String", "H5_URL", '"https://s.xuehu365.com/"')
buildConfigField("boolean", "isEncode", "true")
buildConfigField("boolean", "isOpenUmeng", "true")
buildConfigField("String", "APPId", '"xuehu"')
buildConfigField("String", "JPushAlias", '""')
buildConfigField("String", "JPushTags", '"prd"')
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
output.outputFile = new File(file.parent, file.name.replace(file.name,
variant.productFlavors[0].name + "_" +
variant.versionName
+ "_prod.apk"))
}
}
}
productFlavors.all {
flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
}
}