VariantBuilder

interface VariantBuilder : ComponentBuilder
com.android.build.api.variant.VariantBuilder

Variant object that contains properties that must be set during configuration time as it changes the build flow for the variant.

Summary

Public methods

abstract Unit
registerExtension(type: Class<out T>, instance: T)

Registers an extension object to the variant object.

Properties

abstract Boolean

Set to true if the variant's has any unit tests, false otherwise.

abstract Int?

Gets the maximum supported SDK Version for this variant.

abstract Int?

Gets or sets the minimum supported SDK Version for this variant.

abstract String?

Gets or sets the minimum supported SDK Version for this variant as a Preview codename.

abstract Int

Specifies the bytecode version to be generated.

abstract Int?

Gets or sets the target SDK Version for this variant as a Preview codename.

abstract String?

Gets or sets the target SDK Version for this variant as a Preview codename.

abstract Boolean

Set to true if the variant's has any unit tests, false otherwise.

Inherited properties

Public methods

registerExtension

abstract fun <T : Any> registerExtension(
    type: Class<out T>,
    instance: T
): Unit

Registers an extension object to the variant object. Extension objects can be looked up during the AndroidComponentsExtension.onVariants callbacks by using the Variant.getExtension API.

This is very useful for third party plugins that want to attach some variant specific configuration object to the Android Gradle Plugin variant object and make it available to other plugins.

Parameters
type: Class<out T> the registered object type (can be a supertype of instance), this is the type that must be passed to the Variant.getExtension API.
instance: T the object to associate to the AGP Variant object.

Properties

enableUnitTest

abstract var enableUnitTest: Boolean

Set to true if the variant's has any unit tests, false otherwise. Value is Boolean#True by default.

maxSdk

abstract var maxSdk: Int?

Gets the maximum supported SDK Version for this variant.

minSdk

abstract var minSdk: Int?

Gets or sets the minimum supported SDK Version for this variant. Setting this it will override previous calls of minSdk and minSdkPreview setters. Only one of minSdk and minSdkPreview should be set.

Return
the minimum supported SDK Version or null if minSdkPreview was used to set it.

minSdkPreview

abstract var minSdkPreview: String?

Gets or sets the minimum supported SDK Version for this variant as a Preview codename. Setting this it will override previous calls of minSdk and minSdkPreview setters. Only one of minSdk and minSdkPreview should be set.

Return
the minimum supported SDK Version or null if minSdk was used to set it.

renderscriptTargetApi

abstract var renderscriptTargetApi: Int

Specifies the bytecode version to be generated. We recommend you set this value to the lowest API level able to provide all the functionality you are using

Return
the renderscript target api or -1 if not specified.

targetSdk

abstract var targetSdk: Int?

Gets or sets the target SDK Version for this variant as a Preview codename. Setting this it will override previous calls of targetSdk and targetSdkPreview setters. Only one of targetSdk and targetSdkPreview should be set.

Return
the target SDK Version or null if targetSdkPreview was used to set it.

targetSdkPreview

abstract var targetSdkPreview: String?

Gets or sets the target SDK Version for this variant as a Preview codename. Setting this it will override previous calls of targetSdk and targetSdkPreview setters. Only one of targetSdk and targetSdkPreview should be set.

Return
the target supported SDK Version or null if targetSdkPreview was used to set it.

unitTestEnabled

abstract var unitTestEnabled: Boolean

Set to true if the variant's has any unit tests, false otherwise. Value is Boolean#True by default.