Before AGP 7.0.0-alpha15 I could change version code of an app for example like that
android {
defaultConfig {
applicationVariants.all {
if (buildType.name == "debug") {
outputs.forEach { output ->
(output as? com.android.build.gradle.internal.api.ApkVariantOutputImpl)?.versionCodeOverride = 1
}
}
}
}
}
applicationVariants
seems missing after AGP 7.0.0-alpha15, how to change it?
PS: It seems ok in plain gradle, above is Kotlin
Edit
With answer from below I was able to override version code in build:
android {
androidComponents.onVariants { appVariant ->
if (appVariant.buildType == "release") {
appVariant.outputs.forEach {
it.versionCode.set(1)
}
}
}
}
ApplicationVariant
still exists and hasList<VariantOutput>
. – Evangelia