#gradle #android If you have a setup to publish your APK and you are migrating to Android Gradle Plugin 8.+ you will notice this warning: ``` WARNING: Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property `android.disableAutomaticComponentCreation=true` in the `gradle.properties` file or use the new publishing DSL. ``` AGP 8 won't create components for your artifacts automatically anymore. So this won't work: ```groovy publishing { publications { apk(MavenPublication) { groupId = "your group id" artifactId = "your artifact id" version = "your artifact version" afterEvaluate { from components["release"] } } } } ``` `components` collection is going to be empty and your build will fail: ``` * What went wrong: A problem occurred configuring project ':project'. > Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer. ``` Instead, you need to leverage new API to create a component based on what build variant you want to publish: ```groovy android { ... publishing { singleVariant("release") { // replace release with build variant you want to publish publishApk() // or don't add this if you want to publish a bundle } } } ``` **IMPORTANT**: the name of variant you are setting up to publish and the name of the component you are looking up within you publishing configuration have to match as they refer to the same thing. So if you have product flavors or some custom build types or both you will have to update your code to use proper build variants: ```groovy ... singleVariant("freeAppRelease") ... ``` ```groovy ... from components["freeAppRelease"] ... ``` **Important caveat**: it is impossible to publish multiple variants of an android app (you can publish multiple variants of an android library though). To do that, you will have to add some login to set up your singleVariant based on arguments passed to Gradle. This will be covered in a separate note.