BuildType

@Incubating interface BuildType : Named, VariantDimension, ExtensionAware
com.android.build.api.dsl.BuildType

DSL object to configure build types.

Summary

Public methods

abstract Unit

Copies all properties from the given build type.

abstract Unit

abstract Unit
setMatchingFallbacks(vararg fallbacks: String)

abstract Unit

Inherited functions

Properties

abstract Boolean

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

abstract Boolean

Specifies whether to enable code shrinking for this build type.

abstract Boolean

Specifies whether the plugin should generate resources for pseudolocales.

abstract Boolean

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

abstract Boolean

Specifies whether to enable shrinking resources for this build type.

abstract Boolean

Whether test coverage is enabled for this build type.

abstract Boolean

abstract MutableList<String>

Specifies a sorted list of build types that the plugin should try to use when a direct variant match with a local module dependency is not possible.

abstract PostProcessing

abstract Int

Optimization level to use by the renderscript compiler.

Inherited properties

Public methods

initWith

@Incubating abstract fun initWith(that: BuildType): Unit

Copies all properties from the given build type.

It can be used like this:

android.buildTypes {
    customBuildType {
        initWith debug
        // customize...
    }
}

postprocessing

@Incubating abstract fun postprocessing(action: PostProcessing.() -> Unit): Unit

setMatchingFallbacks

@Incubating abstract fun setMatchingFallbacks(vararg fallbacks: String): Unit

Deprecated.

setMatchingFallbacks

@Incubating abstract fun setMatchingFallbacks(fallbacks: List<String>): Unit

Deprecated.

Properties

isJniDebuggable

abstract var isJniDebuggable: Boolean

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

isMinifyEnabled

abstract var isMinifyEnabled: Boolean

Specifies whether to enable code shrinking for this build type.

By default, when you enable code shrinking by setting this property to true, the Android plugin uses ProGuard.

To learn more, read Shrink Your Code and Resources.

isPseudoLocalesEnabled

abstract var isPseudoLocalesEnabled: Boolean

Specifies whether the plugin should generate resources for pseudolocales.

A pseudolocale is a locale that simulates characteristics of languages that cause UI, layout, and other translation-related problems when an app is localized. Pseudolocales can aid your development workflow because you can test and make adjustments to your UI before you finalize text for translation.

When you set this property to true as shown below, the plugin generates resources for the following pseudo locales and makes them available in your connected device's language preferences: en-XA and ar-XB.

android {
    buildTypes {
        debug {
            pseudoLocalesEnabled true
        }
    }
}

When you build your app, the plugin includes the pseudolocale resources in your APK. If you notice that your APK does not include those locale resources, make sure your build configuration isn't limiting which locale resources are packaged with your APK, such as using the resConfigs property to remove unused locale resources.

To learn more, read Test Your App with Pseudolocales.

isRenderscriptDebuggable

abstract var isRenderscriptDebuggable: Boolean

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

isShrinkResources

abstract var isShrinkResources: Boolean

Specifies whether to enable shrinking resources for this build type.

To learn more, read Shrink Your Code and Resources.

isTestCoverageEnabled

abstract var isTestCoverageEnabled: Boolean

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'
    }
}

isZipAlignEnabled

abstract var isZipAlignEnabled: Boolean

Deprecated.

matchingFallbacks

abstract val matchingFallbacks: MutableList<String>

Specifies a sorted list of build types that the plugin should try to use when a direct variant match with a local module dependency is not possible.

Android plugin 3.0.0 and higher try to match each variant of your module with the same one from its dependencies. For example, when you build a "freeDebug" version of your app, the plugin tries to match it with "freeDebug" versions of the local library modules the app depends on.

However, there may be situations in which your app includes build types that adependency does not. For example, consider if your app includes a "stage" build type, but a dependency includes only a "debug" and "release" build type. When the plugin tries to build the "stage" version of your app, it won't know which version of the dependency to use, and you'll see an error message similar to the following:

Error:Failed to resolve: Could not resolve project :mylibrary.
Required by:
project :app

In this situation, you can use matchingFallbacks to specify alternative matches for the app's "stage" build type, as shown below:

// In the app's build.gradle file.
android {
    buildTypes {
        release {
            // Because the dependency already includes a "release" build type,
            // you don't need to provide a list of fallbacks here.
        }
        stage {
            // Specifies a sorted list of fallback build types that the
            // plugin should try to use when a dependency does not include a
            // "stage" build type. You may specify as many fallbacks as you
            // like, and the plugin selects the first build type that's
            // available in the dependency.
            matchingFallbacks = ['debug', 'qa', 'release']
        }
    }
}

Note that there is no issue when a library dependency includes a build type that your app does not. That's because the plugin simply never requests that build type from the dependency.

Return
the names of product flavors to use, in descending priority order

postprocessing

abstract val postprocessing: PostProcessing

renderscriptOptimLevel

abstract var renderscriptOptimLevel: Int

Optimization level to use by the renderscript compiler.