BaseFlavor

interface BaseFlavor : VariantDimension, HasInitWith<BaseFlavor>
com.android.build.api.dsl.BaseFlavor

Shared properties between DSL objects ProductFlavor and DefaultConfig

Summary

Public methods

abstract String

The name of the flavor.

abstract Unit

Copies all properties from the given flavor.

abstract Unit
minSdkVersion(minSdkVersion: Int)

abstract Unit
minSdkVersion(minSdkVersion: String?)

abstract Unit
missingDimensionStrategy(dimension: String, requestedValue: String)

Specifies a flavor that the plugin should try to use from a given dimension in a dependency.

abstract Unit
missingDimensionStrategy(dimension: String, vararg requestedValues: String)

Specifies a sorted list of flavors that the plugin should try to use from a given dimension in a dependency.

abstract Unit
missingDimensionStrategy(dimension: String, requestedValues: List<String>)

Specifies a sorted list of flavors that the plugin should try to use from a given dimension in a dependency.

abstract Unit
resConfig(config: String)

abstract Unit

abstract Unit
resConfigs(vararg config: String)

abstract Unit
setMinSdkVersion(minSdkVersion: Int)

abstract Unit
setMinSdkVersion(minSdkVersion: String?)

abstract Any?
setTestFunctionalTest(testFunctionalTest: Boolean)

abstract Any?
setTestHandleProfiling(testHandleProfiling: Boolean)

abstract Any?
setTestInstrumentationRunnerArguments(testInstrumentationRunnerArguments: MutableMap<String, String>)

abstract Unit

abstract Unit

abstract Unit

Configures VectorDrawables.

Inherited functions

Properties

abstract Int?

The minimum SDK version.

abstract String?

The minimum SDK version.

abstract Boolean?

Whether the renderscript code should be compiled to generate C/C++ bindings.

abstract Boolean?

Whether the renderscript BLAS support lib should be used to make it compatible with older versions of Android.

abstract Boolean?

Whether the renderscript code should be compiled in support mode to make it compatible with older versions of Android.

abstract Int?

The renderscript target api, or null if not specified.

abstract MutableSet<String>

Specifies a list of alternative resources to keep.

abstract String?

Test application ID.

abstract Boolean?

See instrumentation.

abstract Boolean?

See instrumentation.

abstract String?

Test instrumentation runner class name.

abstract MutableMap<String, String>

Test instrumentation runner custom arguments.

abstract VectorDrawables

Options to configure the build-time support for vector drawables.

abstract Boolean?

Whether to enable unbundling mode for embedded wear app.

Inherited properties

Public methods

getName

@Incubating abstract fun getName(): String

The name of the flavor.

initWith

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

Copies all properties from the given flavor.

It can be used like this:

android.productFlavors {
    paid {
        initWith free
        // customize...
    }
}

minSdkVersion

@Incubating abstract fun minSdkVersion(minSdkVersion: Int): Unit

Deprecated.

minSdkVersion

@Incubating abstract fun minSdkVersion(minSdkVersion: String?): Unit

Deprecated.

missingDimensionStrategy

@Incubating abstract fun missingDimensionStrategy(
    dimension: String,
    requestedValue: String
): Unit

Specifies a flavor that the plugin should try to use from a given dimension in a dependency.

Android plugin 3.0.0 and higher try to match each variant of your module with the same one from its dependencies. For example, consider if both your app and its dependencies include a "tier" flavor dimension, with flavors "free" and "paid". 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 a library dependency includes a flavordimension that your app does not. For example, consider if a library dependency includes flavors for a "minApi" dimension, but your app includes flavors for only the "tier" dimension. So, when you want to build the "freeDebug" version of your app, the plugin doesn't know whether to use the "minApi23Debug" or "minApi18Debug" version of the dependency, 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 type of situation, use missingDimensionStrategy in the defaultConfig block to specify the default flavor the plugin should select from each missing dimension, as shown in the sample below. You can also override your selection in the productFlavors block, so each flavor can specify a different matching strategy for a missing dimension. (Tip: you can also use this property if you simply want to change the matching strategy for a dimension that exists in both the app and its dependencies.)

// In the app's build.gradle file.
android {
    defaultConfig {
        // Specifies a flavor that the plugin should try to use from
        // a given dimension. The following tells the plugin that, when encountering
        // a dependency that includes a "minApi" dimension, it should select the
        // "minApi18" flavor.
        missingDimensionStrategy 'minApi', 'minApi18'
        // You should specify a missingDimensionStrategy property for each
        // dimension that exists in a local dependency but not in your app.
        missingDimensionStrategy 'abi', 'x86'
    }
    flavorDimensions 'tier'
    productFlavors {
        free {
            dimension 'tier'
            // You can override the default selection at the product flavor
            // level by configuring another missingDimensionStrategy property
            // for the "minApi" dimension.
            missingDimensionStrategy 'minApi', 'minApi23'
        }
        paid { }
    }
}

missingDimensionStrategy

@Incubating abstract fun missingDimensionStrategy(
    dimension: String,
    vararg requestedValues: String
): Unit

Specifies a sorted list of flavors that the plugin should try to use from a given dimension in a dependency.

Android plugin 3.0.0 and higher try to match each variant of your module with the same one from its dependencies. For example, consider if both your app and its dependencies include a "tier" flavor dimension, with flavors "free" and "paid". 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 a library dependency includes a flavordimension that your app does not. For example, consider if a library dependency includes flavors for a "minApi" dimension, but your app includes flavors for only the "tier" dimension. So, when you want to build the "freeDebug" version of your app, the plugin doesn't know whether to use the "minApi23Debug" or "minApi18Debug" version of the dependency, 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 type of situation, use missingDimensionStrategy in the defaultConfig block to specify the default flavor the plugin should select from each missing dimension, as shown in the sample below. You can also override your selection in the productFlavors block, so each flavor can specify a different matching strategy for a missing dimension. (Tip: you can also use this property if you simply want to change the matching strategy for a dimension that exists in both the app and its dependencies.)

// In the app's build.gradle file.
android {
    defaultConfig {
        // Specifies a flavor that the plugin should try to use from
        // a given dimension. The following tells the plugin that, when encountering
        // a dependency that includes a "minApi" dimension, it should select the
        // "minApi18" flavor.
        missingDimensionStrategy 'minApi', 'minApi18'
        // You should specify a missingDimensionStrategy property for each
        // dimension that exists in a local dependency but not in your app.
        missingDimensionStrategy 'abi', 'x86'
    }
    flavorDimensions 'tier'
    productFlavors {
        free {
            dimension 'tier'
            // You can override the default selection at the product flavor
            // level by configuring another missingDimensionStrategy property
            // for the "minApi" dimension.
            missingDimensionStrategy 'minApi', 'minApi23'
        }
        paid { }
    }
}

missingDimensionStrategy

@Incubating abstract fun missingDimensionStrategy(
    dimension: String,
    requestedValues: List<String>
): Unit

Specifies a sorted list of flavors that the plugin should try to use from a given dimension in a dependency.

Android plugin 3.0.0 and higher try to match each variant of your module with the same one from its dependencies. For example, consider if both your app and its dependencies include a "tier" flavor dimension, with flavors "free" and "paid". 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 a library dependency includes a flavordimension that your app does not. For example, consider if a library dependency includes flavors for a "minApi" dimension, but your app includes flavors for only the "tier" dimension. So, when you want to build the "freeDebug" version of your app, the plugin doesn't know whether to use the "minApi23Debug" or "minApi18Debug" version of the dependency, 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 type of situation, use missingDimensionStrategy in the defaultConfig block to specify the default flavor the plugin should select from each missing dimension, as shown in the sample below. You can also override your selection in the productFlavors block, so each flavor can specify a different matching strategy for a missing dimension. (Tip: you can also use this property if you simply want to change the matching strategy for a dimension that exists in both the app and its dependencies.)

// In the app's build.gradle file.
android {
    defaultConfig {
        // Specifies a flavor that the plugin should try to use from
        // a given dimension. The following tells the plugin that, when encountering
        // a dependency that includes a "minApi" dimension, it should select the
        // "minApi18" flavor.
        missingDimensionStrategy 'minApi', 'minApi18'
        // You should specify a missingDimensionStrategy property for each
        // dimension that exists in a local dependency but not in your app.
        missingDimensionStrategy 'abi', 'x86'
    }
    flavorDimensions 'tier'
    productFlavors {
        free {
            dimension 'tier'
            // You can override the default selection at the product flavor
            // level by configuring another missingDimensionStrategy property
            // for the "minApi" dimension.
            missingDimensionStrategy 'minApi', 'minApi23'
        }
        paid { }
    }
}

resConfig

@Incubating abstract fun resConfig(config: String): Unit

Deprecated.

resConfigs

@Incubating abstract fun resConfigs(config: Collection<String>): Unit

Deprecated.

resConfigs

@Incubating abstract fun resConfigs(vararg config: String): Unit

Deprecated.

setMinSdkVersion

@Incubating abstract fun setMinSdkVersion(minSdkVersion: Int): Unit

Deprecated.

setMinSdkVersion

@Incubating abstract fun setMinSdkVersion(minSdkVersion: String?): Unit

Deprecated.

setTestFunctionalTest

@Incubating abstract fun setTestFunctionalTest(testFunctionalTest: Boolean): Any?

Deprecated.

setTestHandleProfiling

@Incubating abstract fun setTestHandleProfiling(testHandleProfiling: Boolean): Any?

Deprecated.

setTestInstrumentationRunnerArguments

@Incubating abstract fun setTestInstrumentationRunnerArguments(testInstrumentationRunnerArguments: MutableMap<String, String>): Any?

Deprecated.

testInstrumentationRunnerArgument

@Incubating abstract fun testInstrumentationRunnerArgument(
    key: String,
    value: String
): Unit

Deprecated.

testInstrumentationRunnerArguments

@Incubating abstract fun testInstrumentationRunnerArguments(args: Map<String, String>): Unit

Deprecated.

vectorDrawables

@Incubating abstract fun vectorDrawables(action: VectorDrawables.() -> Unit): Unit

Configures VectorDrawables.

Properties

minSdk

abstract var minSdk: Int?

The minimum SDK version. Setting this it will override previous calls of minSdk and minSdkPreview setters. Only one of minSdk and minSdkPreview should be set.

See uses-sdk element documentation.

minSdkPreview

abstract var minSdkPreview: String?

The minimum SDK version. Setting this it will override previous calls of minSdk and minSdkPreview setters. Only one of minSdk and minSdkPreview should be set.

See uses-sdk element documentation.

renderscriptNdkModeEnabled

abstract var renderscriptNdkModeEnabled: Boolean?

Whether the renderscript code should be compiled to generate C/C++ bindings. True for C/C++ generation, false for Java, null if not specified.

renderscriptSupportModeBlasEnabled

abstract var renderscriptSupportModeBlasEnabled: Boolean?

Whether the renderscript BLAS support lib should be used to make it compatible with older versions of Android.

True if BLAS support lib is enabled, false if not, and null if not specified.

renderscriptSupportModeEnabled

abstract var renderscriptSupportModeEnabled: Boolean?

Whether the renderscript code should be compiled in support mode to make it compatible with older versions of Android.

True if support mode is enabled, false if not, and null if not specified.

renderscriptTargetApi

abstract var renderscriptTargetApi: Int?

The renderscript target api, or null if not specified. This is only the value set on this product flavor.

resourceConfigurations

abstract val resourceConfigurations: MutableSet<String>

Specifies a list of alternative resources to keep.

For example, if you are using a library that includes language resources (such as AppCompat or Google Play Services), then your APK includes all translated language strings for the messages in those libraries whether the rest of your app is translated to the same languages or not. If you'd like to keep only the languages that your app officially supports, you can specify those languages using the resourceConfigurations property, as shown in the sample below. Any resources for languages not specified are removed.

android {
    defaultConfig {
        ...
        // Keeps language resources for only the locales specified below.
        resourceConfigurations += ["en", "fr"]
    }
}

You can also use this property to filter resources for screen densities. For example, specifying hdpi removes all other screen density resources (such as mdpi, xhdpi, etc) from the final APK.

Note: auto is no longer supported because it created a number of issues with multi-module projects. Instead, you should specify a list of locales that your app supports, as shown in the sample above. Android plugin 3.1.0 and higher ignore the auto argument, and Gradle packages all string resources your app and its dependencies provide.

To learn more, see Remove unused alternative resources.

testApplicationId

abstract var testApplicationId: String?

Test application ID.

See Set the Application ID

testFunctionalTest

abstract var testFunctionalTest: Boolean?

See instrumentation.

testHandleProfiling

abstract var testHandleProfiling: Boolean?

See instrumentation.

testInstrumentationRunner

abstract var testInstrumentationRunner: String?

Test instrumentation runner class name.

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

See instrumentation.

testInstrumentationRunnerArguments

abstract val testInstrumentationRunnerArguments: MutableMap<String, String>

Test instrumentation runner custom arguments.

e.g. [key: "value"] will give adb shell am instrument -w -e key value com.example...

See instrumentation.

Test runner arguments can also be specified from the command line:

./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.size=medium
./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.foo=bar

vectorDrawables

abstract val vectorDrawables: VectorDrawables

Options to configure the build-time support for vector drawables.

wearAppUnbundled

abstract var wearAppUnbundled: Boolean?

Whether to enable unbundling mode for embedded wear app.

If true, this enables the app to transition from an embedded wear app to one distributed by the play store directly.