ProductFlavor

DSL object used to configure product flavors.

Properties

PropertyDescription
applicationId

The application ID.

consumerProguardFiles

ProGuard rule files to be included in the published AAR.

dimension

Name of the dimension this product flavor belongs to.

manifestPlaceholders

The manifest placeholders.

multiDexEnabled

Whether Multi-Dex is enabled for this variant.

proguardFiles

Returns ProGuard configuration files to be used.

signingConfig

Signing config used by this product flavor.

testApplicationId

Test application ID.

testFunctionalTest

See instrumentation.

testHandleProfiling

See instrumentation.

testInstrumentationRunner

Test instrumentation runner class name.

useJack

Whether the experimental Jack toolchain should be used.

versionCode

Version code.

versionName

Version name.

Methods

MethodDescription
maxSdkVersion(targetSdkVersion)

Sets the maximum SDK version to the given value.

minSdkVersion(minSdkVersion)

Sets minimum SDK version.

minSdkVersion(minSdkVersion)

Sets minimum SDK version.

proguardFile(proguardFile)

Adds a new ProGuard configuration file.

proguardFiles(proguardFileArray)

Adds new ProGuard configuration files.

resConfig(config)

Adds a resource configuration filter.

resConfigs(config)

Adds several resource configuration filters.

resConfigs(config)

Adds several resource configuration filters.

resValue(type, name, value)

Adds a new generated resource.

setProguardFiles(proguardFileIterable)

Sets the ProGuard configuration files.

targetSdkVersion(targetSdkVersion)

Sets the target SDK version to the given value.

targetSdkVersion(targetSdkVersion)

Sets the target SDK version to the given value.

useJack(useJack)

Whether the experimental Jack toolchain should be used.

Script blocks

No script blocks

Property details

String applicationId

The application ID.

See ApplicationId versus PackageName

List<File> consumerProguardFiles (read-only)

ProGuard rule files to be included in the published AAR.

These proguard rule files will then be used by any application project that consumes the AAR (if ProGuard is enabled).

This allows AAR to specify shrinking or obfuscation exclude rules.

This is only valid for Library project. This is ignored in Application project.

String dimension

Name of the dimension this product flavor belongs to.

Map<String, Object> manifestPlaceholders

The manifest placeholders.

See Manifest merger.

Boolean multiDexEnabled

Whether Multi-Dex is enabled for this variant.

List<File> proguardFiles (read-only)

Returns ProGuard configuration files to be used.

There are 2 default rules files

  • proguard-android.txt
  • proguard-android-optimize.txt

They are located in the SDK. Using getDefaultProguardFile(String filename) will return the full path to the files. They are identical except for enabling optimizations.

See similarly named methods to specify the files.

SigningConfig signingConfig (read-only)

Signing config used by this product flavor.

String testApplicationId

Test application ID.

See ApplicationId versus PackageName

Boolean testFunctionalTest

See instrumentation.

Boolean testHandleProfiling

See instrumentation.

String testInstrumentationRunner

Test instrumentation runner class name.

This is a fully qualified class name of the runner, e.g. android.test.InstrumentationTestRunner

See instrumentation.

Boolean useJack

Whether the experimental Jack toolchain should be used.

See Jack and Jill

Integer versionCode

Version code.

See Versioning Your Application

String versionName

Version name.

See Versioning Your Application

Method details

void maxSdkVersion(int targetSdkVersion)

Sets the maximum SDK version to the given value.

See uses-sdk element documentation.

void minSdkVersion(int minSdkVersion)

Sets minimum SDK version.

See uses-sdk element documentation.

void minSdkVersion(String minSdkVersion)

Sets minimum SDK version.

See uses-sdk element documentation.

void proguardFile(Object proguardFile)

Adds a new ProGuard configuration file.

proguardFile getDefaultProguardFile('proguard-android.txt')

There are 2 default rules files

  • proguard-android.txt
  • proguard-android-optimize.txt

They are located in the SDK. Using getDefaultProguardFile(String filename) will return the full path to the files. They are identical except for enabling optimizations.

void proguardFiles(Object... proguardFileArray)

Adds new ProGuard configuration files.

There are 2 default rules files

  • proguard-android.txt
  • proguard-android-optimize.txt

They are located in the SDK. Using getDefaultProguardFile(String filename) will return the full path to the files. They are identical except for enabling optimizations.

void resConfig(String config)

Adds a resource configuration filter.

If a qualifier value is passed, then all other resources using a qualifier of the same type but of different value will be ignored from the final packaging of the APK.

For instance, specifying 'hdpi', will ignore all resources using mdpi, xhdpi, etc...

void resConfigs(String... config)

Adds several resource configuration filters.

If a qualifier value is passed, then all other resources using a qualifier of the same type but of different value will be ignored from the final packaging of the APK.

For instance, specifying 'hdpi', will ignore all resources using mdpi, xhdpi, etc...

void resConfigs(Collection<String> config)

Adds several resource configuration filters.

If a qualifier value is passed, then all other resources using a qualifier of the same type but of different value will be ignored from the final packaging of the APK.

For instance, specifying 'hdpi', will ignore all resources using mdpi, xhdpi, etc...

void resValue(String type, String name, String value)

Adds a new generated resource.

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

See Resource Types.

void setProguardFiles(Iterable<?> proguardFileIterable)

Sets the ProGuard configuration files.

There are 2 default rules files

  • proguard-android.txt
  • proguard-android-optimize.txt

They are located in the SDK. Using getDefaultProguardFile(String filename) will return the full path to the files. They are identical except for enabling optimizations.

void targetSdkVersion(int targetSdkVersion)

Sets the target SDK version to the given value.

See uses-sdk element documentation.

void targetSdkVersion(String targetSdkVersion)

Sets the target SDK version to the given value.

See uses-sdk element documentation.

void useJack(Boolean useJack)

Whether the experimental Jack toolchain should be used.

See Jack and Jill