VariantDimension

@Incubating interface VariantDimension
com.android.build.api.dsl.VariantDimension

Shared properties between DSL objects that contribute to a variant.

That is, BuildType and ProductFlavor and DefaultConfig.

Summary

Public methods

abstract Unit
addManifestPlaceholders(manifestPlaceholders: Map<String, Any>)

Adds manifest placeholders.

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

Adds a new field to the generated BuildConfig class.

abstract Unit

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

abstract Unit

Options for configuring Java compilation.

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

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

abstract Any
proguardFile(proguardFile: Any)

Adds a new ProGuard configuration file.

abstract Any
proguardFiles(vararg files: Any)

Adds new ProGuard configuration files.

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

Adds a new generated resource.

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

Configure the shader compiler options.

abstract Any
testProguardFile(proguardFile: Any)

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

abstract Any
testProguardFiles(vararg proguardFiles: Any)

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

Properties

abstract ExternalNativeBuildOptions

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

abstract JavaCompileOptions

Options for configuring Java compilation.

abstract MutableMap<String, Any>

The manifest placeholders.

abstract File?

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

abstract File?

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

abstract Ndk

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

abstract MutableList<File>

Specifies the ProGuard configuration files that the plugin should use.

abstract Shaders

Options for configuring the shader compiler.

abstract MutableList<File>

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

Public methods

addManifestPlaceholders

abstract fun addManifestPlaceholders(manifestPlaceholders: Map<String, Any>): Unit

Adds manifest placeholders.

See Inject Build Variables into the Manifest.

buildConfigField

abstract 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

abstract fun externalNativeBuild(action: 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

abstract fun javaCompileOptions(action: JavaCompileOptions.() -> Unit): Unit

Options for configuring Java compilation.

ndk

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

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

proguardFile

abstract 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 getDefaultProguardFileString to return the full path of the files.

This method has a return value for legacy reasons.

proguardFiles

abstract 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 getDefaultProguardFileString to return the full path of the files.

This method has a return value for legacy reasons.

resValue

abstract 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

shaders

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

Configure the shader compiler options.

testProguardFile

abstract 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

abstract 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.

Properties

externalNativeBuild

abstract val externalNativeBuild: ExternalNativeBuildOptions

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

abstract val javaCompileOptions: JavaCompileOptions

Options for configuring Java compilation.

manifestPlaceholders

abstract val manifestPlaceholders: MutableMap<String, Any>

The manifest placeholders.

See Inject Build Variables into the Manifest.

multiDexKeepFile

abstract var multiDexKeepFile: File?

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

abstract var multiDexKeepProguard: File?

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

abstract val ndk: Ndk

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

proguardFiles

abstract val proguardFiles: MutableList<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 getDefaultProguardFileString to return the full path of the files.

Return
a non-null collection of files.

shaders

abstract val shaders: Shaders

Options for configuring the shader compiler.

testProguardFiles

abstract val testProguardFiles: MutableList<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.