Android library要发布到Maven,升级到Gradle 8.0之后报错 Could not get unknown property ‘release’ for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.
解决方法
在module的build.gradle的android节点下,添加:
android { publishing { singleVariant("release") { withSourcesJar() withJavadocJar() } multipleVariants { withSourcesJar() withJavadocJar() allVariants() } } }
原因
Software Components are 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.
参考文献
https://stackoverflow.com/a/77141507