Stay organized with collections
Save and categorize content based on your preferences.
Publishing
interface Publishing<SingleVariantT : SingleVariant>
Known direct subclasses
ApplicationPublishing |
Maven publishing DSL object for configuring options related to publishing APK and AAB.
|
LibraryPublishing |
Maven publishing DSL object for configuring options related to publishing AAR.
|
Maven publishing DSL object for configuring options related to publishing Android variants to a Maven repository.
Android Gradle Plugin 7.1.0 and higher allows you to configure which build variants to publish to an Apache Maven repository. Android Gradle Plugin creates components for those variants in your app or library module that you can use to customize a publication to a Maven repository. You are able to publish build variants in two different publishing mechanisms: single variant publishing and multiple variants publishing.
In single variant publishing, Android Gradle Plugin creates a component for the variant you want to publish in your app or library module. The component has the same name as the variant and only contains that single variant. For modules that use the application plugin, Android Gradle Plugin publishes the variant as an Android App Bundle(AAB) by default. You can publish the variant as a ZIP of APK(s) instead by using ApplicationSingleVariant.publishApk
inside the singleVariant config block. However, publishing the variant as AAB and APK together is not supported.
Multiple variants publishing allows you to publish multiple variants in your library module and choose the name of the component those variants are added to. The component name is set to “default” unless you specify it in the multipleVariants function call. Android Gradle Plugin adds necessary variant specific attributes including buildType and flavorDimensions to disambiguate those variants. Note that multiple variants publishing is not supported in app modules.
LibraryPublishing
extends this with options for publishing library projects. ApplicationPublishing
extends this with options for publishing application projects.
Summary
Public functions |
Unit |
Publish a variant with single variant publishing mechanism.
|
Unit |
Publish a variant with single variant publishing options.
|
Public functions
singleVariant
fun singleVariant(variantName: String): Unit
Publish a variant with single variant publishing mechanism.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Publishing\n==========\n\n\n```\ninterface Publishing\u003cSingleVariantT : SingleVariant\u003e\n```\n\n\u003cbr /\u003e\n\nKnown direct subclasses \n[ApplicationPublishing](/reference/tools/gradle-api/8.1/com/android/build/api/dsl/ApplicationPublishing), [LibraryPublishing](/reference/tools/gradle-api/8.1/com/android/build/api/dsl/LibraryPublishing) \n\n|----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|\n| [ApplicationPublishing](/reference/tools/gradle-api/8.1/com/android/build/api/dsl/ApplicationPublishing) | Maven publishing DSL object for configuring options related to publishing APK and AAB. |\n| [LibraryPublishing](/reference/tools/gradle-api/8.1/com/android/build/api/dsl/LibraryPublishing) | Maven publishing DSL object for configuring options related to publishing AAR. |\n\n*** ** * ** ***\n\nMaven publishing DSL object for configuring options related to publishing Android variants to a Maven repository.\n\nAndroid Gradle Plugin 7.1.0 and higher allows you to configure which build variants to publish to an Apache Maven repository. Android Gradle Plugin creates components for those variants in your app or library module that you can use to customize a publication to a Maven repository. You are able to publish build variants in two different publishing mechanisms: single variant publishing and multiple variants publishing.\n\nIn single variant publishing, Android Gradle Plugin creates a component for the variant you want to publish in your app or library module. The component has the same name as the variant and only contains that single variant. For modules that use the application plugin, Android Gradle Plugin publishes the variant as an Android App Bundle(AAB) by default. You can publish the variant as a ZIP of APK(s) instead by using [ApplicationSingleVariant.publishApk](/reference/tools/gradle-api/8.1/com/android/build/api/dsl/ApplicationSingleVariant#publishApk()) inside the singleVariant config block. However, publishing the variant as AAB and APK together is not supported.\n\nMultiple variants publishing allows you to publish multiple variants in your library module and choose the name of the component those variants are added to. The component name is set to \"default\" unless you specify it in the multipleVariants function call. Android Gradle Plugin adds necessary variant specific attributes including buildType and flavorDimensions to disambiguate those variants. Note that multiple variants publishing is not supported in app modules.\n\n[LibraryPublishing](/reference/tools/gradle-api/8.1/com/android/build/api/dsl/LibraryPublishing) extends this with options for publishing library projects. [ApplicationPublishing](/reference/tools/gradle-api/8.1/com/android/build/api/dsl/ApplicationPublishing) extends this with options for publishing application projects.\n\nSummary\n-------\n\n| ### Public functions ||\n|------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [singleVariant](/reference/tools/gradle-api/8.1/com/android/build/api/dsl/Publishing#singleVariant(kotlin.String))`(variantName: `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Publish a variant with single variant publishing mechanism. |\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [singleVariant](/reference/tools/gradle-api/8.1/com/android/build/api/dsl/Publishing#singleVariant(kotlin.String,kotlin.Function1))`(` ` variantName: `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`,` ` action: @`[ExtensionFunctionType](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-extension-function-type/index.html)` SingleVariantT.() `-\u003e` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) `)` Publish a variant with single variant publishing options. |\n\nPublic functions\n----------------\n\n### singleVariant\n\n```\nfun singleVariant(variantName: String): Unit\n```\n\nPublish a variant with single variant publishing mechanism. \n\n### singleVariant\n\n```\nfun singleVariant(\n variantName: String,\n action: @ExtensionFunctionType SingleVariantT.() -\u003e Unit\n): Unit\n```\n\nPublish a variant with single variant publishing options."]]