Stay organized with collections
Save and categorize content based on your preferences.
VariantExtensionConfig
@Incubating interface VariantExtensionConfig<VariantT : Variant>
Configuration object passed to the lambda responsible for creating a com.android.build.api.variant.VariantExtension
for each com.android.build.api.variant.Variant
instance.
Summary
Public functions |
T |
Returns the variant specific extension registered through the com.android.build.api.extension.DslExtension.buildTypeExtensionType API.
|
List<T> |
Returns the variant specific extension registered through the com.android.build.api.extension.DslExtension.productFlavorExtensionType API.
|
T |
Returns the project (across variants) extension registered through the com.android.build.api.extension.DslExtension.projectExtensionType API.
|
Public functions
buildTypeExtension
fun <T : Any?> buildTypeExtension(extensionType: Class<T>): T
Returns the variant
specific extension registered through the com.android.build.api.extension.DslExtension.buildTypeExtensionType API.
Returns |
T |
the custom extension for the variant 's build type.
|
productFlavorsExtensions
fun <T : Any?> productFlavorsExtensions(extensionType: Class<T>): List<T>
Returns the variant
specific extension registered through the com.android.build.api.extension.DslExtension.productFlavorExtensionType API.
Returns |
List<T> |
a List of T extension for all the defined product flavors in the project. The order of the elements is the same as the order of product flavors returned by the Variant.productFlavors
|
projectExtension
fun <T : Any?> projectExtension(extensionType: Class<T>): T
Returns the project (across variants) extension registered through the com.android.build.api.extension.DslExtension.projectExtensionType API.
Public properties
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.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# VariantExtensionConfig\n======================\n\n\n```\n@Incubating interface VariantExtensionConfig\u003cVariantT : Variant\u003e\n```\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nConfiguration object passed to the lambda responsible for creating a [com.android.build.api.variant.VariantExtension](/reference/tools/gradle-api/8.0/com/android/build/api/variant/VariantExtension) for each [com.android.build.api.variant.Variant](/reference/tools/gradle-api/8.0/com/android/build/api/variant/Variant) instance. \n\n| Parameters ||\n|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|\n| `\u003cVariantT : `[Variant](/reference/tools/gradle-api/8.0/com/android/build/api/variant/Variant)`\u003e` | the type of [com.android.build.api.variant.Variant](/reference/tools/gradle-api/8.0/com/android/build/api/variant/Variant) object. |\n\nSummary\n-------\n\n| ### Public functions ||\n|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `T` | `\u003cT : `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`?\u003e `[buildTypeExtension](/reference/tools/gradle-api/8.0/com/android/build/api/variant/VariantExtensionConfig#buildTypeExtension(java.lang.Class))`(extensionType: `[Class](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html)`\u003cT\u003e)` Returns the [variant](/reference/tools/gradle-api/8.0/com/android/build/api/variant/VariantExtensionConfig#variant()) specific extension registered through the com.android.build.api.extension.DslExtension.buildTypeExtensionType API. |\n| [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`\u003cT\u003e` | `\u003cT : `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`?\u003e `[productFlavorsExtensions](/reference/tools/gradle-api/8.0/com/android/build/api/variant/VariantExtensionConfig#productFlavorsExtensions(java.lang.Class))`(extensionType: `[Class](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html)`\u003cT\u003e)` Returns the [variant](/reference/tools/gradle-api/8.0/com/android/build/api/variant/VariantExtensionConfig#variant()) specific extension registered through the com.android.build.api.extension.DslExtension.productFlavorExtensionType API. |\n| `T` | `\u003cT : `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`?\u003e `[projectExtension](/reference/tools/gradle-api/8.0/com/android/build/api/variant/VariantExtensionConfig#projectExtension(java.lang.Class))`(extensionType: `[Class](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html)`\u003cT\u003e)` Returns the project (across variants) extension registered through the com.android.build.api.extension.DslExtension.projectExtensionType API. |\n\n| ### Public properties ||\n|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `VariantT` | [variant](/reference/tools/gradle-api/8.0/com/android/build/api/variant/VariantExtensionConfig#variant()) Gets the variant object the [com.android.build.api.variant.VariantExtension](/reference/tools/gradle-api/8.0/com/android/build/api/variant/VariantExtension) should be associated with. |\n\nPublic functions\n----------------\n\n### buildTypeExtension\n\n```\nfun \u003cT : Any?\u003e buildTypeExtension(extensionType: Class\u003cT\u003e): T\n```\n\nReturns the [variant](/reference/tools/gradle-api/8.0/com/android/build/api/variant/VariantExtensionConfig#variant()) specific extension registered through the com.android.build.api.extension.DslExtension.buildTypeExtensionType API. \n\n| Returns ||\n|-----|------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `T` | the custom extension for the [variant](/reference/tools/gradle-api/8.0/com/android/build/api/variant/VariantExtensionConfig#variant())'s build type. |\n\n### productFlavorsExtensions\n\n```\nfun \u003cT : Any?\u003e productFlavorsExtensions(extensionType: Class\u003cT\u003e): List\u003cT\u003e\n```\n\nReturns the [variant](/reference/tools/gradle-api/8.0/com/android/build/api/variant/VariantExtensionConfig#variant()) specific extension registered through the com.android.build.api.extension.DslExtension.productFlavorExtensionType API. \n\n| Returns ||\n|-----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`\u003cT\u003e` | a [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html) of [T](/reference/tools/gradle-api/8.0/com/android/build/api/variant/VariantExtensionConfig#productFlavorsExtensions(java.lang.Class)) extension for all the defined product flavors in the project. The order of the elements is the same as the order of product flavors returned by the [Variant.productFlavors](/reference/tools/gradle-api/8.0/com/android/build/api/variant/Variant#productFlavors()) |\n\n### projectExtension\n\n```\nfun \u003cT : Any?\u003e projectExtension(extensionType: Class\u003cT\u003e): T\n```\n\nReturns the project (across variants) extension registered through the com.android.build.api.extension.DslExtension.projectExtensionType API.\n\nPublic properties\n-----------------\n\n### variant\n\n```\nval variant: VariantT\n```\n\nGets the variant object the [com.android.build.api.variant.VariantExtension](/reference/tools/gradle-api/8.0/com/android/build/api/variant/VariantExtension) should be associated with."]]