VariantDimension

Added in 4.2.0

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

Shared properties between ApplicationProductFlavor and ApplicationDefaultConfig

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 DynamicFeatureProductFlavor and DynamicFeatureDefaultConfig

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

Shared properties between LibraryProductFlavor and LibraryDefaultConfig

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

Shared properties between TestProductFlavor and TestDefaultConfig

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

Unit
addManifestPlaceholders(manifestPlaceholders: Map<StringAny>)

Adds manifest placeholders.

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

Adds a new field to the generated BuildConfig class.

Unit

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

Unit

Options for configuring Java compilation.

Unit
ndk(action: Ndk.() -> Unit)

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

Unit
Any
proguardFile(proguardFile: Any)

Adds a new ProGuard configuration file.

Any
proguardFiles(vararg files: Any)

Adds new ProGuard configuration files.

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

Adds a new generated resource.

Void?
setManifestPlaceholders(manifestPlaceholders: Map<StringAny>)

This function is deprecated. Use manifestPlaceholders property instead

Any
setProguardFiles(proguardFileIterable: Iterable<*>)

Replaces the ProGuard configuration files.

Unit
shaders(action: Shaders.() -> Unit)

Configure the shader compiler options.

Any
testProguardFile(proguardFile: Any)

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

Any
testProguardFiles(vararg proguardFiles: Any)

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

Public properties

ExternalNativeBuildFlags

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

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

Adds manifest placeholders.

See Inject Build Variables into the Manifest.

buildConfigField

Added in 4.2.0
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

Added in 8.0.2
@Incubating
fun externalNativeBuild(action: ExternalNativeBuildFlags.() -> 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

Added in 4.2.0
fun javaCompileOptions(action: JavaCompileOptions.() -> Unit): Unit

Options for configuring Java compilation.

ndk

Added in 4.2.0
fun ndk(action: Ndk.() -> Unit): Unit

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

optimization

Added in 7.3.0
@Incubating
fun optimization(action: Optimization.() -> Unit): Unit

proguardFile

Added in 4.2.0
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

Added in 4.2.0
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

Added in 4.2.0
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

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

setProguardFiles

Added in 7.0.0
fun setProguardFiles(proguardFileIterable: Iterable<*>): Any

Replaces the ProGuard configuration files.

This method has a return value for legacy reasons.

shaders

Added in 4.2.0
fun shaders(action: Shaders.() -> Unit): Unit

Configure the shader compiler options.

testProguardFile

Added in 4.2.0
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

Added in 4.2.0
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

Added in 4.2.0
val externalNativeBuildExternalNativeBuildFlags

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

Added in 4.2.0
val javaCompileOptionsJavaCompileOptions

Options for configuring Java compilation.

manifestPlaceholders

Added in 4.2.0
val manifestPlaceholdersMutableMap<StringAny>

The manifest placeholders.

See Inject Build Variables into the Manifest.

multiDexKeepFile

Added in 4.2.0
Deprecated in 7.0.0
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

Added in 4.2.0
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

Added in 4.2.0
val ndkNdk

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

optimization

Added in 7.3.0
val optimizationOptimization

proguardFiles

Added in 4.2.0
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

Added in 4.2.0
val shadersShaders

Options for configuring the shader compiler.

testProguardFiles

Added in 4.2.0
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.