BuildType

DSL object to configure build types.

Properties

PropertyDescription
applicationIdSuffix

Application id suffix applied to this build type.

consumerProguardFiles

ProGuard rule files to be included in the published AAR.

debuggable

Whether this build type should generate a debuggable apk.

embedMicroApp

Whether a linked Android Wear app should be embedded in variant using this build type.

jniDebuggable

Whether this build type is configured to generate an APK with debuggable native code.

manifestPlaceholders

The manifest placeholders.

minifyEnabled

Whether Minify is enabled for this build type.

multiDexEnabled

Whether Multi-Dex is enabled for this variant.

name

Name of this build type.

proguardFiles

Returns ProGuard configuration files to be used.

pseudoLocalesEnabled

Whether to generate pseudo locale in the APK.

renderscriptDebuggable

Whether the build type is configured to generate an apk with debuggable RenderScript code.

renderscriptOptimLevel

Optimization level to use by the renderscript compiler.

shrinkResources

Whether shrinking of unused resources is enabled. Default is false;

signingConfig

The signing configuration.

testCoverageEnabled

Whether test coverage is enabled for this build type.

useJack

Whether the experimental Jack toolchain should be used.

versionNameSuffix

Version name suffix.

zipAlignEnabled

Whether zipalign is enabled for this build type.

Methods

MethodDescription
buildConfigField(type, name, value)

Adds a new field to the generated BuildConfig class.

proguardFile(proguardFile)

Adds a new ProGuard configuration file.

proguardFiles(proguardFileArray)

Adds new ProGuard configuration files.

resValue(type, name, value)

Adds a new generated resource.

resValue(type, name, value)

Adds a new generated resource.

setProguardFiles(proguardFileIterable)

Sets the ProGuard configuration files.

shrinkResources(flag)

Whether shrinking of unused resources is enabled. Default is false;

useJack(useJack)

Whether the experimental Jack toolchain should be used.

Script blocks

No script blocks

Property details

String applicationIdSuffix

Application id suffix applied to this build type.

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.

boolean debuggable

Whether this build type should generate a debuggable apk.

boolean embedMicroApp

Whether a linked Android Wear app should be embedded in variant using this build type.

Wear apps can be linked with the following code:

dependencies {
  freeWearApp project(:wear:free') // applies to variant using the free flavor
  wearApp project(':wear:base') // applies to all other variants
}

boolean jniDebuggable

Whether this build type is configured to generate an APK with debuggable native code.

Map<String, Object> manifestPlaceholders

The manifest placeholders.

See Manifest merger.

boolean minifyEnabled

Whether Minify is enabled for this build type.

Boolean multiDexEnabled

Whether Multi-Dex is enabled for this variant.

String name (read-only)

Name of this build type.

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.

boolean pseudoLocalesEnabled

Whether to generate pseudo locale in the APK.

If enabled, 2 fake pseudo locales (en-XA and ar-XB) will be added to the APK to help test internationalization support in the app.

boolean renderscriptDebuggable

Whether the build type is configured to generate an apk with debuggable RenderScript code.

int renderscriptOptimLevel

Optimization level to use by the renderscript compiler.

boolean shrinkResources

Whether shrinking of unused resources is enabled. Default is false;

SigningConfig signingConfig (read-only)

The signing configuration.

boolean testCoverageEnabled

Whether test coverage is enabled for this build type.

If enabled this uses Jacoco to capture coverage and creates a report in the build directory.

The version of Jacoco can be configured with:

android {
  jacoco {
    version = '0.6.2.201302030002'
  }
}

Boolean useJack

Whether the experimental Jack toolchain should be used.

String versionNameSuffix

Version name suffix.

boolean zipAlignEnabled

Whether zipalign is enabled for this build type.

Method details

void buildConfigField(String type, String name, 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.

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

BuildType proguardFiles(Object... proguardFileArray)

Adds new ProGuard configuration files.

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

Adds a new generated resource.

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

Adds a new generated resource.

BuildType setProguardFiles(Iterable<?> proguardFileIterable)

Sets the ProGuard configuration files.

void shrinkResources(boolean flag)

Whether shrinking of unused resources is enabled. Default is false;

void useJack(Boolean useJack)

Whether the experimental Jack toolchain should be used.