在build.gradle文件android节点下配置
productFlavors {
htd {}
htk {}
}
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "钢筋笼${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}.apk"
}
}
static def releaseTime() {
return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}
不同渠道使用不同lib,先去掉implementation fileTree(dir: 'libs', include: ['*.jar'])
然后添加指定lib 格式 渠道名+Implementation
如下
htdImplementation files('libs/380d_mtk6755_jar_v1.0.jar')
htkImplementation files('libs/Jb380_Common_V1.3.jar')
当遇见All flavors must now belong to a named flavor dimension..
错误时在defaultConfig
节点配置flavorDimensions "versionCode"
如下:
defaultConfig {
applicationId "com.ohoyee.steelQualityInspection"
minSdkVersion 19
targetSdkVersion 28
versionCode 2
versionName "1.1"
flavorDimensions "versionCode"
multiDexEnabled true
}