Gradle alpha version 3.0.0 release

I want to have a different type of assembly versionCode for debug , and not an assembly type release . This was used to work using the configuration below in the Gradle Android plug-in v2.3.2 (Gradle v3.3), but now has no effect in version v.0.0.0-alpha5 (Gradle v4.1-stage-1). Any ideas on what has changed in the latest 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()) } } } } 
+5
source share
2 answers

As a workaround before release 3.0, if someone is looking for a solution, you can use:

 output.setVersionCodeOverride(Integer.parseInt(buildTimeSmall())) 

Thanks Jerome link: https://issuetracker.google.com/issues/63785806#comment6

+6
source

From the migration guide :

Using the API to control output options breaks down with the new plugin. It still works for simple tasks, such as changing the name of the APK during build, as shown below:

 // If you use each() to iterate through the variant objects, // you need to start using all(). That because each() iterates // through only the objects that already exist during configuration timeโ€” // but those object don't exist at configuration time with the new model. // However, all() adapts to the new model by picking up object as they are // added during execution. android.applicationVariants.all { variant -> variant.outputs.all { outputFileName = "${variant.name}-${variant.versionName}.apk" } } 

However, more complex tasks associated with accessing outputFile objects no longer work. This is because, at the configuration stage, specific tasks are no longer created. This leads to the fact that the plugin does not know all its outputs in front, but it also means faster setup time. As an alternative, we will introduce new APIs to provide similar functionality.

+2
source

Source: https://habr.com/ru/post/1269925/


All Articles