VariantDimension

public 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 methods

abstract void
addManifestPlaceholders(
    @NonNull Map<@NonNull String, @NonNull Object> manifestPlaceholders
)

Adds manifest placeholders.

abstract void
buildConfigField(
    @NonNull String type,
    @NonNull String name,
    @NonNull String value
)

Adds a new field to the generated BuildConfig class.

abstract void

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

abstract @NonNull ExternalNativeBuildFlags

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

abstract @NonNull JavaCompileOptions

Options for configuring Java compilation.

abstract @NonNull Map<@NonNull String, @NonNull Object>

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 @NonNull Ndk

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

abstract @NonNull Optimization
abstract @NonNull List<@NonNull File>

Specifies the ProGuard configuration files that the plugin should use.

abstract @NonNull Shaders

Options for configuring the shader compiler.

abstract @NonNull List<@NonNull File>

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

abstract void

Options for configuring Java compilation.

abstract void
ndk(@ExtensionFunctionType @NonNull Function1<@NonNull NdkUnit> action)

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

abstract void
abstract @NonNull Object
proguardFile(@NonNull Object proguardFile)

Adds a new ProGuard configuration file.

abstract @NonNull Object

Adds new ProGuard configuration files.

abstract void
resValue(@NonNull String type, @NonNull String name, @NonNull String value)

Adds a new generated resource.

abstract Void
setManifestPlaceholders(
    @NonNull Map<@NonNull String, @NonNull Object> manifestPlaceholders
)

This method is deprecated. Use manifestPlaceholders property instead

abstract void
setMultiDexKeepFile(File multiDexKeepFile)

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

abstract void
setMultiDexKeepProguard(File multiDexKeepProguard)

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

abstract @NonNull Object
setProguardFiles(@NonNull Iterable<@NonNull ?> proguardFileIterable)

Replaces the ProGuard configuration files.

abstract void
shaders(
    @ExtensionFunctionType @NonNull Function1<@NonNull ShadersUnit> action
)

Configure the shader compiler options.

abstract @NonNull Object

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

abstract @NonNull Object

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

Public methods

addManifestPlaceholders

abstract void addManifestPlaceholders(
    @NonNull Map<@NonNull String, @NonNull Object> manifestPlaceholders
)

Adds manifest placeholders.

See Inject Build Variables into the Manifest.

buildConfigField

abstract void buildConfigField(
    @NonNull String type,
    @NonNull String name,
    @NonNull String value
)

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
@NonNull String type

the type of the field

@NonNull String name

the name of the field

@NonNull String value

the value of the field

externalNativeBuild

@Incubating
abstract void externalNativeBuild(
    @ExtensionFunctionType @NonNull Function1<@NonNull ExternalNativeBuildFlagsUnit> action
)

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.

getExternalNativeBuild

@Incubating
abstract @NonNull ExternalNativeBuildFlags getExternalNativeBuild()

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.

getJavaCompileOptions

abstract @NonNull JavaCompileOptions getJavaCompileOptions()

Options for configuring Java compilation.

getManifestPlaceholders

abstract @NonNull Map<@NonNull String, @NonNull ObjectgetManifestPlaceholders()

The manifest placeholders.

See Inject Build Variables into the Manifest.

getMultiDexKeepFile

abstract File getMultiDexKeepFile()

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

getMultiDexKeepProguard

abstract File getMultiDexKeepProguard()

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.

getNdk

abstract @NonNull Ndk getNdk()

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

getOptimization

@Incubating
abstract @NonNull Optimization getOptimization()

getProguardFiles

abstract @NonNull List<@NonNull FilegetProguardFiles()

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
@NonNull List<@NonNull File>

a non-null collection of files.

getShaders

abstract @NonNull Shaders getShaders()

Options for configuring the shader compiler.

getTestProguardFiles

abstract @NonNull List<@NonNull FilegetTestProguardFiles()

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.

javaCompileOptions

abstract void javaCompileOptions(
    @ExtensionFunctionType @NonNull Function1<@NonNull JavaCompileOptionsUnit> action
)

Options for configuring Java compilation.

ndk

abstract void ndk(@ExtensionFunctionType @NonNull Function1<@NonNull NdkUnit> action)

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

optimization

@Incubating
abstract void optimization(
    @ExtensionFunctionType @NonNull Function1<@NonNull OptimizationUnit> action
)

proguardFile

abstract @NonNull Object proguardFile(@NonNull Object proguardFile)

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

abstract @NonNull Object proguardFiles(@NonNull Object files)

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

abstract void resValue(@NonNull String type, @NonNull String name, @NonNull String value)

Adds a new generated resource.

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

See Resource Types.

Parameters
@NonNull String type

the type of the resource

@NonNull String name

the name of the resource

@NonNull String value

the value of the resource

setManifestPlaceholders

abstract Void setManifestPlaceholders(
    @NonNull Map<@NonNull String, @NonNull Object> manifestPlaceholders
)

setMultiDexKeepFile

abstract void setMultiDexKeepFile(File multiDexKeepFile)

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

setMultiDexKeepProguard

abstract void setMultiDexKeepProguard(File multiDexKeepProguard)

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.

setProguardFiles

abstract @NonNull Object setProguardFiles(@NonNull Iterable<@NonNull ?> proguardFileIterable)

Replaces the ProGuard configuration files.

This method has a return value for legacy reasons.

shaders

abstract void shaders(
    @ExtensionFunctionType @NonNull Function1<@NonNull ShadersUnit> action
)

Configure the shader compiler options.

testProguardFile

abstract @NonNull Object testProguardFile(@NonNull Object proguardFile)

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 @NonNull Object testProguardFiles(@NonNull Object proguardFiles)

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.