Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle 3.0.0 alpha variant output issue

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())
                    }
                }
            }
}
like image 523
Bogdan Zurac Avatar asked Jul 18 '17 07:07

Bogdan Zurac


1 Answers

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

like image 97
Bogdan Zurac Avatar answered Oct 05 '22 11:10

Bogdan Zurac