VariantDimension

interface VariantDimension

Known direct subclasses
ApplicationVariantDimension

Shared properties between DSL objects that contribute to an application variant.

BaseFlavor

Shared properties between DSL objects ProductFlavor and DefaultConfig

BuildType

Build types define certain properties that Gradle uses when building and packaging your app, and are typically configured for different stages of your development lifecycle.

DynamicFeatureVariantDimension

Shared properties between DSL objects that contribute to an dynamic feature variant.

LibraryVariantDimension

Shared properties between DSL objects that contribute to a library variant.

TestVariantDimension

Shared properties between DSL objects that contribute to a separate-test-project variant.

Known indirect subclasses
ApplicationBaseFlavor
ApplicationBuildType

Build types define certain properties that Gradle uses when building and packaging your app, and are typically configured for different stages of your development lifecycle.

ApplicationDefaultConfig

Specifies defaults for properties that the Android application plugin applies to all build variants.

ApplicationProductFlavor

Encapsulates all product flavors properties for application projects.

DefaultConfig

Specifies defaults for variant properties that the Android plugin applies to all build variants.

DynamicFeatureBaseFlavor

Shared properties between DSL objects ProductFlavor and DefaultConfig for dynamic features.

DynamicFeatureBuildType

Build types define certain properties that Gradle uses when building and packaging your app, and are typically configured for different stages of your development lifecycle.

DynamicFeatureDefaultConfig

Specifies defaults for properties that the Android dynamic-feature plugin applies to all build variants.

DynamicFeatureProductFlavor

Encapsulates all product flavors properties for dynamic feature projects.

LibraryBaseFlavor
LibraryBuildType

Build types define certain properties that Gradle uses when building and packaging your library, and are typically configured for different stages of your development lifecycle.

LibraryDefaultConfig

Specifies defaults for properties that the Android library plugin applies to all build variants.

LibraryProductFlavor

Encapsulates all product flavors properties for library projects.

ProductFlavor

Encapsulates all product flavors properties for this project.

TestBaseFlavor
TestBuildType

Build types define certain properties that Gradle uses when building and packaging your library, and are typically configured for different stages of your development lifecycle.

TestDefaultConfig

Specifies defaults for properties that the Android test plugin applies to all build variants.

TestProductFlavor

Encapsulates all product flavors properties for test projects.


Shared properties between DSL objects that contribute to a variant.

That is, BuildType and ProductFlavor and DefaultConfig.

Summary

Public functions

@Incubating Unit
addManifestPlaceholders(manifestPlaceholders: Map<StringAny>)

Adds manifest placeholders.

@Incubating Unit
buildConfigField(type: String, name: String, value: String)

Adds a new field to the generated BuildConfig class.

@Incubating Unit

Encapsulates per-variant CMake and ndk-build configurations for your external native build.

Unit

Options for configuring Java compilation.

@Incubating Unit

Encapsulates per-variant configurations for the NDK, such as ABI filters.

@Incubating Unit
@Incubating Any
proguardFile(proguardFile: Any)

Adds a new ProGuard configuration file.

@Incubating Any
proguardFiles(vararg files: Any)

Adds new ProGuard configuration files.

@Incubating Unit
resValue(type: String, name: String, value: String)

Adds a new generated resource.

@Incubating Void?
setManifestPlaceholders(manifestPlaceholders: Map<StringAny>)

This function is deprecated. Use manifestPlaceholders property instead

@Incubating Any
setProguardFiles(proguardFileIterable: Iterable<*>)

Replaces the ProGuard configuration files.

@Incubating Unit

Configure the shader compiler options.

@Incubating Any
testProguardFile(proguardFile: Any)

Adds a proguard rule file to be used when processing test code.

@Incubating Any
testProguardFiles(vararg proguardFiles: Any)

Adds proguard rule files to be used when processing test code.

Public properties

ExternalNativeBuildOptions

Encapsulates per-variant CMake and ndk-build configurations for your external native build.

JavaCompileOptions

Options for configuring Java compilation.

MutableMap<StringAny>

The manifest placeholders.

File?

This property is deprecated. This property is deprecated.

File?

Text file with additional ProGuard rules to be used to determine which classes are compiled into the main dex file.

Ndk

Encapsulates per-variant configurations for the NDK, such as ABI filters.

Optimization
MutableList<File>

Specifies the ProGuard configuration files that the plugin should use.

Shaders

Options for configuring the shader compiler.

MutableList<File>

The collection of proguard rule files to be used when processing test code.

Public functions

addManifestPlaceholders

@Incubating
fun addManifestPlaceholders(manifestPlaceholders: Map<StringAny>): Unit

Adds manifest placeholders.

See Inject Build Variables into the Manifest.

buildConfigField

@Incubating
fun buildConfigField(type: String, name: String, value: String): Unit

Adds a new field to the generated BuildConfig class.

The field is generated as: <type> <name> = <value>;

This means each of these must have valid Java content. If the type is a String, then the value should include quotes.

Parameters
type: String

the type of the field

name: String

the name of the field

value: String

the value of the field

externalNativeBuild

@Incubating
fun externalNativeBuild(action: @ExtensionFunctionType ExternalNativeBuildOptions.() -> Unit): Unit

Encapsulates per-variant CMake and ndk-build configurations for your external native build.

To learn more, see Add C and C++ Code to Your Project.

javaCompileOptions

fun javaCompileOptions(action: @ExtensionFunctionType JavaCompileOptions.() -> Unit): Unit

Options for configuring Java compilation.

ndk

@Incubating
fun ndk(action: @ExtensionFunctionType Ndk.() -> Unit): Unit

Encapsulates per-variant configurations for the NDK, such as ABI filters.

optimization

@Incubating
fun optimization(action: @ExtensionFunctionType Optimization.() -> Unit): Unit

proguardFile

@Incubating
fun proguardFile(proguardFile: Any): Any

Adds a new ProGuard configuration file.

proguardFile getDefaultProguardFile('proguard-android.txt')

There are two ProGuard rules files that ship with the Android plugin and are used by default:

  • proguard-android.txt

  • proguard-android-optimize.txt

proguard-android-optimize.txt is identical to proguard-android.txt, except with optimizations enabled. You can use getDefaultProguardFile(String) to return the full path of the files.

This method has a return value for legacy reasons.

proguardFiles

@Incubating
fun proguardFiles(vararg files: Any): Any

Adds new ProGuard configuration files.

There are two ProGuard rules files that ship with the Android plugin and are used by default:

  • proguard-android.txt

  • proguard-android-optimize.txt

proguard-android-optimize.txt is identical to proguard-android.txt, except with optimizations enabled. You can use getDefaultProguardFile(String) to return the full path of the files.

This method has a return value for legacy reasons.

resValue

@Incubating
fun resValue(type: String, name: String, value: String): Unit

Adds a new generated resource.

This is equivalent to specifying a resource in res/values.

See Resource Types.

Parameters
type: String

the type of the resource

name: String

the name of the resource

value: String

the value of the resource

setManifestPlaceholders

@Incubating
fun setManifestPlaceholders(manifestPlaceholders: Map<StringAny>): Void?

setProguardFiles

@Incubating
fun setProguardFiles(proguardFileIterable: Iterable<*>): Any

Replaces the ProGuard configuration files.

This method has a return value for legacy reasons.

shaders

@Incubating
fun shaders(action: @ExtensionFunctionType Shaders.() -> Unit): Unit

Configure the shader compiler options.

testProguardFile

@Incubating
fun testProguardFile(proguardFile: Any): Any

Adds a proguard rule file to be used when processing test code.

Test code needs to be processed to apply the same obfuscation as was done to main code.

This method has a return value for legacy reasons.

testProguardFiles

@Incubating
fun testProguardFiles(vararg proguardFiles: Any): Any

Adds proguard rule files to be used when processing test code.

Test code needs to be processed to apply the same obfuscation as was done to main code.

This method has a return value for legacy reasons.

Public properties

externalNativeBuild

val externalNativeBuildExternalNativeBuildOptions

Encapsulates per-variant CMake and ndk-build configurations for your external native build.

To learn more, see Add C and C++ Code to Your Project.

javaCompileOptions

val javaCompileOptionsJavaCompileOptions

Options for configuring Java compilation.

manifestPlaceholders

val manifestPlaceholdersMutableMap<StringAny>

The manifest placeholders.

See Inject Build Variables into the Manifest.

multiDexKeepFile

var multiDexKeepFileFile?

Text file that specifies additional classes that will be compiled into the main dex file.

Classes specified in the file are appended to the main dex classes computed using aapt.

If set, the file should contain one class per line, in the following format: com/example/MyClass.class

multiDexKeepProguard

var multiDexKeepProguardFile?

Text file with additional ProGuard rules to be used to determine which classes are compiled into the main dex file.

If set, rules from this file are used in combination with the default rules used by the build system.

ndk

val ndkNdk

Encapsulates per-variant configurations for the NDK, such as ABI filters.

optimization

val optimizationOptimization

proguardFiles

val proguardFilesMutableList<File>

Specifies the ProGuard configuration files that the plugin should use.

There are two ProGuard rules files that ship with the Android plugin and are used by default:

  • proguard-android.txt

  • proguard-android-optimize.txt

proguard-android-optimize.txt is identical to proguard-android.txt, except with optimizations enabled. You can use getDefaultProguardFile(String) to return the full path of the files.

Returns
MutableList<File>

a non-null collection of files.

shaders

val shadersShaders

Options for configuring the shader compiler.

testProguardFiles

val testProguardFilesMutableList<File>

The collection of proguard rule files to be used when processing test code.

Test code needs to be processed to apply the same obfuscation as was done to main code.