友盟 as 3.0多渠道打包配置
as升级到3.0多渠道打包和以前不一样了
我就以图文展示描述下as 3.0打包的全过程
1.
2.
defaultConfig {
applicationId "com.sxcoal"
minSdkVersion 16
targetSdkVersion 27
versionCode 18
versionName "1.1.8"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
flavorDimensions "versionCode" //特别注意 不写这句话会出错 百度有很多解释 我就不复制了
}
3.
//签名 signingConfigs { release { storeFile file("../meitan.jks")//签名文件 storePassword "123456" keyAlias "meitanchina" keyPassword "123456" } }
//3.0 替换成all 了 下边是最简单的写法
applicationVariants.all { variant ->
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = outputFile.name.replace(".apk", "-${defaultConfig.versionName}.apk")
outputFileName = fileName
}
}
}
4.
多渠道配置
productFlavors { sxcoal {} yingyongbao {} xiaomi {} oppo {} } productFlavors.all { flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name] }
然后就可以了