问题描述
我想为 debug 构建类型而不是版本代码 >版本构建类型。这用于在Gradle Android插件v2.3.2(Gradle v3.3)中使用下面的配置来工作,但现在在v3.0.0-alpha5(Gradle v4.1-milestone-1)中没有任何效果。任何关于在最新的Gradle插件中发生了什么变化,使其忽略 variant.mergedFlavor.versionCode 属性?
buildTypes {
debug {
applicationIdSuffix.debug
versionNameSuffix - + buildTime()
android.applicationVariants.all {variant - >
if(variant.buildType.name!= buildTypes.debug.name)返回
variant.outputs.all {
outputFileName =$ {archivesBaseName} - $ {variant.name} -v $ {variant.versionName} -signed.apk
variant.mergedFlavor.versionCode = Integer.parseInt(buildTimeSmall())
}
}
}
}
作为3.0版本之前的解决方法,如果有人正在寻找对于解决方案,您可以使用:
$ p $ output.setVersionCodeOverride(Integer.parseInt(buildTimeSmall()))
感谢杰罗姆,请参阅:
I want to have a different versionCode for debug build type rather than the one in release build type. This used to work by using the configuration from below in Gradle Android plugin v2.3.2 (Gradle v3.3), but doesn't have any effect now in v3.0.0-alpha5 (Gradle v4.1-milestone-1). Any ideas as to what changed in the newest Gradle plugin that makes it ignore the variant.mergedFlavor.versionCode attribute?
buildTypes { debug { applicationIdSuffix ".debug" versionNameSuffix "-" + buildTime() android.applicationVariants.all { variant -> if (variant.buildType.name != buildTypes.debug.name) return variant.outputs.all { outputFileName = "${archivesBaseName}-${variant.name}-v${variant.versionName}-signed.apk" variant.mergedFlavor.versionCode = Integer.parseInt(buildTimeSmall()) } } } }
As a workaround before the 3.0 release, if anybody is looking for a solution, you can use:
output.setVersionCodeOverride(Integer.parseInt(buildTimeSmall()))
Thanks to Jerome, reference: https://issuetracker.google.com/issues/63785806#comment6
这篇关于Gradle 3.0.0 alpha变体输出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!