What happened?
After upgrading an Android project to Gradle 9 my CI build failed with the following error message:
Could not set unknown property 'archivesBaseName'
for project ':app' of type org.gradle.api.Project.
The cause
Culprit is the code in my app/build.gradle.kts
file to change the filename of the generated APK/AAB files when building on a CI server.
android {
defaultConfig {
...
if (isBuildServer()) {
setProperty("archivesBaseName", "$applicationId-$versionName-$versionCode")
}
....
}
}
It turns out the archivesBaseName
property has been deprecated for quite a while and was finally removed in Gradle 9.0.0.
The solution
The Gradle 9.0.0 upgrade instructions
are very cryptic but the solution is fairly simple. You can replace the above code with similar code that uses the base.archivesName
property.
android {
...
}
base {
if (isBuildServer()) {
archivesName = "${android.defaultConfig.applicationId}-${android.defaultConfig.versionName}-${android.defaultConfig.versionCode}"
}
}
Happy upgrading!