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 methods
|
abstract Unit |
Publish a variant with single variant publishing mechanism.
|
abstract Unit |
Publish a variant with single variant publishing options.
|
Public methods
singleVariant
abstract fun singleVariant(variantName: String): Unit
Publish a variant with single variant publishing mechanism.
singleVariant
abstract fun singleVariant(
variantName: String,
action: SingleVariantT.() -> Unit
): Unit
Publish a variant with single variant publishing options.
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```\ninterface Publishing\u003cSingleVariantT : SingleVariant\u003e\n```\n\n|-------------------------------------------|\n| [com.android.build.api.dsl.Publishing](#) |\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [ApplicationPublishing](/reference/tools/gradle-api/7.1/com/android/build/api/dsl/ApplicationPublishing), [LibraryPublishing](/reference/tools/gradle-api/7.1/com/android/build/api/dsl/LibraryPublishing) |----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------| | [ApplicationPublishing](/reference/tools/gradle-api/7.1/com/android/build/api/dsl/ApplicationPublishing) | Maven publishing DSL object for configuring options related to publishing APK and AAB. | | [LibraryPublishing](/reference/tools/gradle-api/7.1/com/android/build/api/dsl/LibraryPublishing) | Maven publishing DSL object for configuring options related to publishing AAR. | |\n\nMaven publishing DSL object for configuring options related to publishing Android variants to a\nMaven repository.\n\nAndroid Gradle Plugin 7.1.0 and higher allows you to configure which build variants to publish\nto an Apache Maven repository. Android Gradle Plugin creates components for those variants in\nyour app or library module that you can use to customize a publication to a Maven repository.\nYou are able to publish build variants in two different publishing mechanisms:\nsingle variant publishing and multiple variants publishing.\n\nIn single variant publishing, Android Gradle Plugin creates a component for the variant you want\nto publish in your app or library module. The component has the same name as the variant and only\ncontains that single variant. For modules that use the application plugin, Android Gradle Plugin\npublishes the variant as an Android App Bundle(AAB) by default. You can publish the variant as\na ZIP of APK(s) instead by using [ApplicationSingleVariant.publishApk](/reference/tools/gradle-api/7.1/com/android/build/api/dsl/ApplicationSingleVariant#publishApk()) inside the singleVariant\nconfig 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\nchoose the name of the component those variants are added to. The component name is set to\n\"default\" unless you specify it in the multipleVariants function call. Android Gradle Plugin adds\nnecessary variant specific attributes including buildType and flavorDimensions to disambiguate\nthose variants. Note that multiple variants publishing is not supported in app modules.\n\n[LibraryPublishing](/reference/tools/gradle-api/7.1/com/android/build/api/dsl/LibraryPublishing) extends this with options for publishing library projects.\n[ApplicationPublishing](/reference/tools/gradle-api/7.1/com/android/build/api/dsl/ApplicationPublishing) extends this with options for publishing application projects.\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [singleVariant](#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| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [singleVariant](#singleVariant(kotlin.String,%20kotlin.Function1))`(`variantName:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `action:` `SingleVariantT.()` `-\u003e` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)` Publish a variant with single variant publishing options. |\n\nPublic methods\n--------------\n\n### singleVariant\n\n```\nabstract fun singleVariant(variantName: String): Unit\n```\n\nPublish a variant with single variant publishing mechanism. \n\n### singleVariant\n\n```\nabstract fun singleVariant(\n variantName: String, \n action: SingleVariantT.() -\u003e Unit\n): Unit\n```\n\nPublish a variant with single variant publishing options."]]