public class DefaultProductFlavor
extends com.android.builder.internal.BaseConfigImpl
implements com.android.builder.model.ProductFlavor
| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultProductFlavor.DimensionRequest
Class representing a request with fallbacks.
|
| Constructor and Description |
|---|
DefaultProductFlavor(java.lang.String name)
Creates a ProductFlavor with a given name.
|
DefaultProductFlavor(java.lang.String name,
DefaultVectorDrawablesOptions vectorDrawablesOptions) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_initWith(com.android.builder.model.BaseConfig that) |
void |
addResourceConfiguration(java.lang.String configuration)
Adds a res config filter (for instance 'hdpi')
|
void |
addResourceConfigurations(java.util.Collection<java.lang.String> configurations)
Adds a res config filter (for instance 'hdpi')
|
void |
addResourceConfigurations(java.lang.String... configurations)
Adds a res config filter (for instance 'hdpi')
|
protected static <T> T |
chooseNotNull(T overlay,
T base) |
static DefaultProductFlavor |
clone(com.android.builder.model.ProductFlavor productFlavor)
Clone a given product flavor.
|
protected void |
cloneFrom(com.android.builder.model.ProductFlavor flavor) |
protected DefaultProductFlavor.DimensionRequest |
computeRequestedAndFallBacks(java.util.List<java.lang.String> requestedValues)
Computes the requested value and the fallback list from the list of values provided in the
DSL
|
java.lang.String |
getApplicationId()
Returns the application ID.
|
java.lang.String |
getDimension() |
java.lang.Integer |
getMaxSdkVersion() |
com.android.builder.model.ApiVersion |
getMinSdkVersion()
Min SDK version.
|
java.util.Map<java.lang.String,DefaultProductFlavor.DimensionRequest> |
getMissingDimensionStrategies() |
java.lang.String |
getName() |
java.lang.Boolean |
getRenderscriptNdkModeEnabled() |
java.lang.Boolean |
getRenderscriptSupportModeBlasEnabled() |
java.lang.Boolean |
getRenderscriptSupportModeEnabled() |
java.lang.Integer |
getRenderscriptTargetApi() |
java.util.Collection<java.lang.String> |
getResourceConfigurations()
Adds a res config filter (for instance 'hdpi')
|
com.android.builder.model.SigningConfig |
getSigningConfig()
Signing config used by this product flavor.
|
com.android.builder.model.ApiVersion |
getTargetSdkVersion()
Target SDK version.
|
java.lang.String |
getTestApplicationId()
Test application ID.
|
java.lang.Boolean |
getTestFunctionalTest()
See
instrumentation.
|
java.lang.Boolean |
getTestHandleProfiling()
See
instrumentation.
|
java.lang.String |
getTestInstrumentationRunner()
Test instrumentation runner class name.
|
java.util.Map<java.lang.String,java.lang.String> |
getTestInstrumentationRunnerArguments()
Test instrumentation runner custom arguments.
|
DefaultVectorDrawablesOptions |
getVectorDrawables()
Options to configure the build-time support for
vector drawables. |
java.lang.Integer |
getVersionCode()
Version code.
|
java.lang.String |
getVersionName()
Version name.
|
java.lang.Boolean |
getWearAppUnbundled()
Returns whether to enable unbundling mode for embedded wear app.
|
static java.lang.String |
mergeApplicationIdSuffix(java.lang.String overlay,
java.lang.String base) |
static com.android.builder.model.ProductFlavor |
mergeFlavors(com.android.builder.model.ProductFlavor lowestPriority,
java.util.List<? extends com.android.builder.model.ProductFlavor> flavors)
Merges the flavors by analyzing the specified one and the list.
|
static java.lang.String |
mergeVersionNameSuffix(java.lang.String overlay,
java.lang.String base) |
void |
missingDimensionStrategy(java.lang.String dimension,
java.util.List<java.lang.String> requestedValues)
Specifies a sorted list of flavors that the plugin should try to use from a given dimension
in a dependency.
|
void |
missingDimensionStrategy(java.lang.String dimension,
java.lang.String... requestedValues)
Specifies a sorted list of flavors that the plugin should try to use from a given dimension
in a dependency.
|
void |
missingDimensionStrategy(java.lang.String dimension,
java.lang.String requestedValue)
Specifies a flavor that the plugin should try to use from a given dimension in a dependency.
|
com.android.builder.model.ProductFlavor |
setApplicationId(java.lang.String applicationId)
Sets the application id.
|
void |
setDimension(java.lang.String dimension) |
com.android.builder.model.ProductFlavor |
setMaxSdkVersion(java.lang.Integer maxSdkVersion) |
com.android.builder.model.ProductFlavor |
setMinSdkVersion(com.android.builder.model.ApiVersion minSdkVersion)
Sets the minSdkVersion to the given value.
|
com.android.builder.model.ProductFlavor |
setRenderscriptNdkModeEnabled(java.lang.Boolean renderscriptNdkMode)
Sets whether the renderscript code should be compiled to generate C/C++ bindings.
|
com.android.builder.model.ProductFlavor |
setRenderscriptSupportModeBlasEnabled(java.lang.Boolean renderscriptSupportModeBlas)
Sets whether RenderScript BLAS support lib should be used to make it compatible
with older versions of Android.
|
com.android.builder.model.ProductFlavor |
setRenderscriptSupportModeEnabled(java.lang.Boolean renderscriptSupportMode)
Sets whether the renderscript code should be compiled in support mode to make it compatible
with older versions of Android.
|
void |
setRenderscriptTargetApi(java.lang.Integer renderscriptTargetApi)
Sets the renderscript target API to the given value.
|
com.android.builder.model.ProductFlavor |
setSigningConfig(com.android.builder.model.SigningConfig signingConfig)
Sets the signing configuration.
|
com.android.builder.model.ProductFlavor |
setTargetSdkVersion(com.android.builder.model.ApiVersion targetSdkVersion)
Sets the targetSdkVersion to the given value.
|
com.android.builder.model.ProductFlavor |
setTestApplicationId(java.lang.String applicationId)
Sets the test application ID.
|
com.android.builder.model.ProductFlavor |
setTestFunctionalTest(boolean functionalTest) |
com.android.builder.model.ProductFlavor |
setTestHandleProfiling(boolean handleProfiling) |
com.android.builder.model.ProductFlavor |
setTestInstrumentationRunner(java.lang.String testInstrumentationRunner)
Sets the test instrumentation runner to the given value.
|
com.android.builder.model.ProductFlavor |
setTestInstrumentationRunnerArguments(java.util.Map<java.lang.String,java.lang.String> testInstrumentationRunnerArguments)
Sets the test instrumentation runner custom arguments.
|
com.android.builder.model.ProductFlavor |
setVersionCode(java.lang.Integer versionCode)
Sets the version code.
|
com.android.builder.model.ProductFlavor |
setVersionName(java.lang.String versionName)
Sets the version name.
|
void |
setWearAppUnbundled(java.lang.Boolean wearAppUnbundled)
Sets whether to enable unbundling mode for embedded wear app.
|
java.lang.String |
toString() |
addBuildConfigField, addBuildConfigFields, addManifestPlaceholders, addResValue, addResValues, getApplicationIdSuffix, getBuildConfigFields, getConsumerProguardFiles, getManifestPlaceholders, getMultiDexEnabled, getMultiDexKeepFile, getMultiDexKeepProguard, getProguardFiles, getResValues, getTestProguardFiles, getVersionNameSuffix, setApplicationIdSuffix, setManifestPlaceholders, setMultiDexEnabled, setMultiDexKeepFile, setMultiDexKeepProguard, setVersionNameSuffixclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetApplicationIdSuffix, getBuildConfigFields, getConsumerProguardFiles, getManifestPlaceholders, getMultiDexEnabled, getMultiDexKeepFile, getMultiDexKeepProguard, getProguardFiles, getResValues, getTestProguardFiles, getVersionNameSuffixpublic DefaultProductFlavor(@NonNull
java.lang.String name)
name - the name of the flavor.BuilderConstants.MAINpublic DefaultProductFlavor(@NonNull
java.lang.String name,
@NonNull
DefaultVectorDrawablesOptions vectorDrawablesOptions)
@NonNull public java.lang.String getName()
getName in interface com.android.builder.model.BaseConfiggetName in interface com.android.builder.model.ProductFlavorpublic void setDimension(@NonNull
java.lang.String dimension)
@Nullable public java.lang.String getDimension()
getDimension in interface com.android.builder.model.DimensionAware@NonNull public com.android.builder.model.ProductFlavor setApplicationId(java.lang.String applicationId)
@Nullable public java.lang.String getApplicationId()
getApplicationId in interface com.android.builder.model.ProductFlavor@NonNull public com.android.builder.model.ProductFlavor setVersionCode(java.lang.Integer versionCode)
versionCode - the version code@Nullable public java.lang.Integer getVersionCode()
getVersionCode in interface com.android.builder.model.ProductFlavor@NonNull public com.android.builder.model.ProductFlavor setVersionName(java.lang.String versionName)
versionName - the version name@Nullable public java.lang.String getVersionName()
getVersionName in interface com.android.builder.model.ProductFlavor@NonNull public com.android.builder.model.ProductFlavor setMinSdkVersion(com.android.builder.model.ApiVersion minSdkVersion)
@Nullable public com.android.builder.model.ApiVersion getMinSdkVersion()
getMinSdkVersion in interface com.android.builder.model.ProductFlavor@NonNull
public com.android.builder.model.ProductFlavor setTargetSdkVersion(@Nullable
com.android.builder.model.ApiVersion targetSdkVersion)
@Nullable public com.android.builder.model.ApiVersion getTargetSdkVersion()
getTargetSdkVersion in interface com.android.builder.model.ProductFlavor@NonNull public com.android.builder.model.ProductFlavor setMaxSdkVersion(java.lang.Integer maxSdkVersion)
@Nullable public java.lang.Integer getMaxSdkVersion()
getMaxSdkVersion in interface com.android.builder.model.ProductFlavor@Nullable public java.lang.Integer getRenderscriptTargetApi()
getRenderscriptTargetApi in interface com.android.builder.model.ProductFlavorpublic void setRenderscriptTargetApi(@Nullable
java.lang.Integer renderscriptTargetApi)
@Nullable public java.lang.Boolean getRenderscriptSupportModeEnabled()
getRenderscriptSupportModeEnabled in interface com.android.builder.model.ProductFlavor@Nullable public java.lang.Boolean getRenderscriptSupportModeBlasEnabled()
getRenderscriptSupportModeBlasEnabled in interface com.android.builder.model.ProductFlavorpublic com.android.builder.model.ProductFlavor setRenderscriptSupportModeEnabled(java.lang.Boolean renderscriptSupportMode)
public com.android.builder.model.ProductFlavor setRenderscriptSupportModeBlasEnabled(java.lang.Boolean renderscriptSupportModeBlas)
@Nullable public java.lang.Boolean getRenderscriptNdkModeEnabled()
getRenderscriptNdkModeEnabled in interface com.android.builder.model.ProductFlavorpublic com.android.builder.model.ProductFlavor setRenderscriptNdkModeEnabled(java.lang.Boolean renderscriptNdkMode)
@NonNull public com.android.builder.model.ProductFlavor setTestApplicationId(java.lang.String applicationId)
@Nullable public java.lang.String getTestApplicationId()
getTestApplicationId in interface com.android.builder.model.ProductFlavor@NonNull public com.android.builder.model.ProductFlavor setTestInstrumentationRunner(java.lang.String testInstrumentationRunner)
@Nullable public java.lang.String getTestInstrumentationRunner()
This is a fully qualified class name of the runner, e.g.
android.test.InstrumentationTestRunner
See instrumentation.
getTestInstrumentationRunner in interface com.android.builder.model.ProductFlavor@NonNull
public com.android.builder.model.ProductFlavor setTestInstrumentationRunnerArguments(@NonNull
java.util.Map<java.lang.String,java.lang.String> testInstrumentationRunnerArguments)
@NonNull public java.util.Map<java.lang.String,java.lang.String> getTestInstrumentationRunnerArguments()
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
getTestInstrumentationRunnerArguments in interface com.android.builder.model.ProductFlavor@Nullable public java.lang.Boolean getTestHandleProfiling()
getTestHandleProfiling in interface com.android.builder.model.ProductFlavor@NonNull public com.android.builder.model.ProductFlavor setTestHandleProfiling(boolean handleProfiling)
@Nullable public java.lang.Boolean getTestFunctionalTest()
getTestFunctionalTest in interface com.android.builder.model.ProductFlavor@NonNull public com.android.builder.model.ProductFlavor setTestFunctionalTest(boolean functionalTest)
@Nullable public com.android.builder.model.SigningConfig getSigningConfig()
getSigningConfig in interface com.android.builder.model.ProductFlavor@NonNull public com.android.builder.model.ProductFlavor setSigningConfig(com.android.builder.model.SigningConfig signingConfig)
signingConfig signingConfigs.myConfig@NonNull public DefaultVectorDrawablesOptions getVectorDrawables()
vector drawables.getVectorDrawables in interface com.android.builder.model.ProductFlavor@Nullable public java.lang.Boolean getWearAppUnbundled()
getWearAppUnbundled in interface com.android.builder.model.ProductFlavorpublic void setWearAppUnbundled(@Nullable
java.lang.Boolean wearAppUnbundled)
public void addResourceConfiguration(@NonNull
java.lang.String configuration)
public void addResourceConfigurations(@NonNull
java.lang.String... configurations)
public void addResourceConfigurations(@NonNull
java.util.Collection<java.lang.String> configurations)
@NonNull public java.util.Collection<java.lang.String> getResourceConfigurations()
getResourceConfigurations in interface com.android.builder.model.ProductFlavorpublic void missingDimensionStrategy(java.lang.String dimension,
java.lang.String requestedValue)
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 flavor dimension 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 {}
}
}
dimension - requestedValue - public void missingDimensionStrategy(java.lang.String dimension,
java.lang.String... requestedValues)
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 flavor dimension 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 sorted list of flavors 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. You can include additional flavor names to provide a
// sorted list of fallbacks for the dimension.
missingDimensionStrategy 'minApi', 'minApi18', 'minApi23'
// You should specify a missingDimensionStrategy property for each
// dimension that exists in a local dependency but not in your app.
missingDimensionStrategy 'abi', 'x86', 'arm64'
}
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', 'minApi18'
}
paid {}
}
}
dimension - requestedValues - public void missingDimensionStrategy(java.lang.String dimension,
java.util.List<java.lang.String> requestedValues)
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 flavor dimension 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 sorted list of flavors 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. You can include additional flavor names to provide a
// sorted list of fallbacks for the dimension.
missingDimensionStrategy 'minApi', 'minApi18', 'minApi23'
// You should specify a missingDimensionStrategy property for each
// dimension that exists in a local dependency but not in your app.
missingDimensionStrategy 'abi', 'x86', 'arm64'
}
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', 'minApi18'
}
paid {}
}
}
dimension - requestedValues - @NonNull protected DefaultProductFlavor.DimensionRequest computeRequestedAndFallBacks(@NonNull java.util.List<java.lang.String> requestedValues)
requestedValues - the values provided in the DSLpublic java.util.Map<java.lang.String,DefaultProductFlavor.DimensionRequest> getMissingDimensionStrategies()
public static com.android.builder.model.ProductFlavor mergeFlavors(@NonNull
com.android.builder.model.ProductFlavor lowestPriority,
@NonNull
java.util.List<? extends com.android.builder.model.ProductFlavor> flavors)
lowestPriority, as the name
says, has the lowest priority of them all, and will always be overwritten.lowestPriority - flavor with the lowest priorityflavors - flavors to merge@NonNull public static DefaultProductFlavor clone(@NonNull com.android.builder.model.ProductFlavor productFlavor)
productFlavor - the flavor to clone.protected void cloneFrom(@NonNull
com.android.builder.model.ProductFlavor flavor)
protected void _initWith(@NonNull
com.android.builder.model.BaseConfig that)
_initWith in class com.android.builder.internal.BaseConfigImplprotected static <T> T chooseNotNull(T overlay,
T base)
public static java.lang.String mergeApplicationIdSuffix(@Nullable
java.lang.String overlay,
@Nullable
java.lang.String base)
public static java.lang.String mergeVersionNameSuffix(@Nullable
java.lang.String overlay,
@Nullable
java.lang.String base)
@NonNull public java.lang.String toString()
toString in class com.android.builder.internal.BaseConfigImpl