A Variant configuration. Variants are made from the combination of: - a build type (base interface BuildType), and its associated sources. - a default configuration (base interface ProductFlavor), and its associated sources. - a optional list of product flavors (base interface ProductFlavor) and their associated sources. - dependencies (both jar and aar).
- the type used for the Build Type.
- the type used for the default config
- the type used for the product flavors.Modifiers | Name | Description |
---|---|---|
static enum |
VariantConfiguration.Type |
Constructor and description |
---|
VariantConfiguration
(D defaultConfig, com.android.builder.model.SourceProvider defaultSourceProvider, T buildType, com.android.builder.model.SourceProvider buildTypeSourceProvider, com.android.builder.model.SigningConfig signingConfigOverride) Creates the configuration with the base source sets. |
VariantConfiguration
(D defaultConfig, com.android.builder.model.SourceProvider defaultSourceProvider, T buildType, com.android.builder.model.SourceProvider buildTypeSourceProvider, VariantConfiguration.Type type, com.android.builder.model.SigningConfig signingConfigOverride) Creates the configuration with the base source sets for a given Type. |
VariantConfiguration
(D defaultConfig, com.android.builder.model.SourceProvider defaultSourceProvider, T buildType, com.android.builder.model.SourceProvider buildTypeSourceProvider, VariantConfiguration.Type type, VariantConfiguration testedConfig, com.android.builder.model.SigningConfig signingConfigOverride) Creates the configuration with the base source sets, and an optional tested variant. |
Type | Name and description |
---|---|
void |
addBuildConfigField(String type, String name, String value) Adds a variant-specific BuildConfig field. |
VariantConfiguration |
addProductFlavor(F productFlavor, com.android.builder.model.SourceProvider sourceProvider, String dimensionName) Add a new configured ProductFlavor. |
void |
addResValue(String type, String name, String value) Adds a variant-specific res value. |
void |
checkSourceProviders() Checks the SourceProviders to ensure that they don't use the same folders. |
String |
computeBaseNameWithSplits(String splitName) Returns a base name that includes the given splits name. |
String |
computeDirNameWithSplits(String... splitNames) Returns a unique directory name (can include multiple folders) for the variant, based on build type, flavor and test, and splits. |
String |
computeFullNameWithSplits(String splitName) Returns a full name that includes the given splits name. |
List<File> |
getAidlImports() Returns all the aidl import folder that are outside of the current project. |
List<File> |
getAidlSourceList() |
List<LibraryDependency> |
getAllLibraries() Returns all the library dependencies, direct and transitive. |
String |
getApplicationId() Returns the application ID for this variant. |
List<com.android.ide.common.res2.AssetSet> |
getAssetSets(List<File> generatedResFolders, boolean includeDependencies) Returns the dynamic list of com.android.ide.common.res2.AssetSet based on the configuration, its dependencies, as well as tested config if applicable (test of a library). |
String |
getBaseName() Returns the full, unique name of the variant, including BuildType, flavors and test, dash separated. |
List<Object> |
getBuildConfigItems() Returns a list of items for the BuildConfig class. |
T |
getBuildType() |
com.android.builder.model.SourceProvider |
getBuildTypeSourceSet() The SourceProvider for the BuildType. |
Set<File> |
getCompileClasspath() Returns the compile classpath for this config. |
List<Object> |
getConsumerProguardFiles() |
D |
getDefaultConfig() |
com.android.builder.model.SourceProvider |
getDefaultSourceSet() |
String |
getDirName() Returns a unique directory name (can include multiple folders) for the variant, based on build type, flavor and test. |
List<LibraryDependency> |
getDirectLibraries() Returns the direct library dependencies |
String |
getFlavorName() Returns the flavor name of the variant, including all flavors in camel case (starting with a lower case). |
List<String> |
getFlavorNamesWithDimensionNames() Return the names of the applied flavors. |
List<com.android.builder.model.SourceProvider> |
getFlavorSourceProviders() Returns the list of SourceProviders for the flavors. |
String |
getFullName() Returns the full, unique name of the variant in camel case (starting with a lower case), including BuildType, Flavors and Test (if applicable). |
Boolean |
getFunctionalTest() Returns functionalTest value to use to test this variant, or if the variant is a test, the one to use to test the tested variant. |
Boolean |
getHandleProfiling() Returns handleProfiling value to use to test this variant, or if the variant is a test, the one to use to test the tested variant. |
String |
getIdOverride() Returns the application id override value coming from the Product Flavor and/or the Build Type. |
String |
getInstrumentationRunner() Returns the instrumentationRunner to use to test this variant, or if the variant is a test, the one to use to test the tested variant. |
Collection<JarDependency> |
getJars() Returns the list of jar dependencies |
List<File> |
getJniLibsList() |
List<File> |
getJniSourceList() |
List<File> |
getLibraryJniFolders() |
File |
getMainManifest() |
List<File> |
getManifestOverlays() |
static String |
getManifestPackage(File manifestFile) A Variant configuration. |
Map<String, Object> |
getManifestPlaceholders() Returns the merged manifest placeholders. |
Map<String, com.android.builder.model.ClassField> |
getMergedBuildConfigFields() Return the merged build config fields for the variant. |
com.android.builder.model.ProductFlavor |
getMergedFlavor() |
Map<String, com.android.builder.model.ClassField> |
getMergedResValues() Return the merged res values for the variant. |
com.android.builder.model.ApiVersion |
getMinSdkVersion() Return the minSdkVersion for this variant. |
File |
getMultiDexKeepFile() |
File |
getMultiDexKeepProguard() |
com.android.builder.model.SourceProvider |
getMultiFlavorSourceProvider() |
String |
getOriginalApplicationId() Returns the original application ID before any overrides from flavors. |
String |
getPackageFromManifest() Reads the package name from the manifest. |
Set<File> |
getPackagedJars() Returns the list of packaged jars for this config. |
List<F> |
getProductFlavors() Returns the product flavors. |
List<File> |
getProguardFiles(boolean includeLibraries, List<File> defaultProguardConfig) Returns the proguard config files coming from the project but also from the dependencies. |
List<File> |
getProvidedOnlyJars() Returns the list of provided-only jars for this config. |
List<File> |
getRenderscriptImports() Returns all the renderscript import folder that are outside of the current project. |
boolean |
getRenderscriptNdkModeEnabled() Returns the renderscript NDK mode. |
List<File> |
getRenderscriptSourceList() Returns all the renderscript source folder from the main config, the flavors and the build type. |
boolean |
getRenderscriptSupportModeEnabled() Returns the renderscript support mode. |
List<Object> |
getResValues() Returns a list of generated resource values. |
List<com.android.ide.common.res2.ResourceSet> |
getResourceSets(List<File> generatedResFolders, boolean includeDependencies) Returns the dynamic list of com.android.ide.common.res2.ResourceSet based on the configuration, its dependencies, as well as tested config if applicable (test of a library). |
com.android.builder.model.SigningConfig |
getSigningConfig() |
List<com.android.builder.model.BaseConfig> |
getSortedBaseConfigs() |
List<com.android.builder.model.SourceProvider> |
getSortedSourceProviders() Returns a list of sorted SourceProvider in order of ascending order, meaning, the earlier items are meant to be overridden by later items. |
com.android.builder.model.ApiVersion |
getTargetSdkVersion() Return the targetSdkVersion for this variant. |
String |
getTestedApplicationId() |
VariantConfiguration |
getTestedConfig() |
VariantConfiguration.Type |
getType() |
com.android.builder.model.SourceProvider |
getVariantSourceProvider() Returns the variant specific source provider |
int |
getVersionCode() Returns the version code for this variant. |
int |
getVersionCodeFromManifest() Reads the version code from the manifest. |
String |
getVersionName() Returns the version name for this variant. |
String |
getVersionNameFromManifest() Reads the version name from the manifest. |
boolean |
hasFlavors() |
boolean |
hasLibraries() |
boolean |
isLegacyMultiDexMode() |
boolean |
isMultiDexEnabled() |
boolean |
isSigningReady() |
boolean |
isTestCoverageEnabled() |
VariantConfiguration |
setDependencies(DependencyContainer container) Sets the dependencies |
VariantConfiguration |
setMultiFlavorSourceProvider(com.android.builder.model.SourceProvider sourceProvider) Sets the variant-specific source provider. |
VariantConfiguration |
setOutput(LibraryDependency output) Sets the output of this variant. |
VariantConfiguration |
setVariantSourceProvider(com.android.builder.model.SourceProvider sourceProvider) Sets the variant-specific source provider. |
Creates the configuration with the base source sets. This creates a config with a Type#DEFAULT#DEFAULT type.
defaultConfig
- the default configuration. Required.defaultSourceProvider
- the default source provider. RequiredbuildType
- the build type for this variant. Required.buildTypeSourceProvider
- the source provider for the build type. Required.Creates the configuration with the base source sets for a given Type.
defaultConfig
- the default configuration. Required.defaultSourceProvider
- the default source provider. RequiredbuildType
- the build type for this variant. Required.buildTypeSourceProvider
- the source provider for the build type.type
- the type of the project.signingConfigOverride
- an optional Signing override to be used for signing.Creates the configuration with the base source sets, and an optional tested variant.
defaultConfig
- the default configuration. Required.defaultSourceProvider
- the default source provider. RequiredbuildType
- the build type for this variant. Required.buildTypeSourceProvider
- the source provider for the build type.type
- the type of the project.testedConfig
- the reference to the tested project. Required if type is Type.TESTsigningConfigOverride
- an optional Signing override to be used for signing.Adds a variant-specific BuildConfig field.
type
- the type of the fieldname
- the name of the fieldvalue
- the value of the fieldAdd a new configured ProductFlavor. If multiple flavors are added, the priority follows the order they are added when it comes to resolving Android resources overlays (ie earlier added flavors supersedes latter added ones).
productFlavor
- the configured product flavorsourceProvider
- the source provider for the product flavordimensionName
- the name of the dimension associated with the flavorAdds a variant-specific res value.
type
- the type of the fieldname
- the name of the fieldvalue
- the value of the fieldChecks the SourceProviders to ensure that they don't use the same folders. This can't be allowed as it can break incremental support, or generate dup files in resulting APK.
Returns a base name that includes the given splits name.
splitName
- the split nameReturns a unique directory name (can include multiple folders) for the variant, based on build type, flavor and test, and splits. This always uses forward slashes ('/') as separator on all platform.
Returns a full name that includes the given splits name.
splitName
- the split nameReturns all the aidl import folder that are outside of the current project.
Returns all the library dependencies, direct and transitive.
Returns the application ID for this variant. This could be coming from the manifest or could be overridden through the product flavors and/or the build type.
Returns the dynamic list of com.android.ide.common.res2.AssetSet based on the configuration, its dependencies, as well as tested config if applicable (test of a library). The list is ordered in ascending order of importance, meaning the first set is meant to be overridden by the 2nd one and so on. This is meant to facilitate usage of the list in a com.android.ide.common.res2.AssetMerger.
Returns the full, unique name of the variant, including BuildType, flavors and test, dash separated. (similar to full name but with dashes)
Returns a list of items for the BuildConfig class. Items can be either fields (instance of com.android.builder.model.ClassField) or comments (instance of String).
The SourceProvider for the BuildType. Can be null.
Returns the compile classpath for this config. If the config tests a library, this will include the classpath of the tested config
Returns a unique directory name (can include multiple folders) for the variant, based on build type, flavor and test. This always uses forward slashes ('/') as separator on all platform.
Returns the direct library dependencies
Returns the flavor name of the variant, including all flavors in camel case (starting with a lower case). If the variant has no flavor, then an empty string is returned.
Return the names of the applied flavors. The list contains the dimension names as well.
Returns the list of SourceProviders for the flavors. The list is ordered from higher priority to lower priority.
Returns the full, unique name of the variant in camel case (starting with a lower case), including BuildType, Flavors and Test (if applicable).
Returns functionalTest value to use to test this variant, or if the variant is a test, the one to use to test the tested variant.
Returns handleProfiling value to use to test this variant, or if the variant is a test, the one to use to test the tested variant.
Returns the application id override value coming from the Product Flavor and/or the Build Type. If the package/id is not overridden then this returns null.
Returns the instrumentationRunner to use to test this variant, or if the variant is a test, the one to use to test the tested variant.
Returns the list of jar dependencies
A Variant configuration. Variants are made from the combination of: - a build type (base interface BuildType), and its associated sources. - a default configuration (base interface ProductFlavor), and its associated sources. - a optional list of product flavors (base interface ProductFlavor) and their associated sources. - dependencies (both jar and aar).
- the type used for the Build Type.
- the type used for the default config
- the type used for the product flavors.Returns the merged manifest placeholders. All product flavors are merged first, then build type specific placeholders are added and potentially overrides product flavors values.
Return the merged build config fields for the variant. This is made of of the variant-specific fields overlayed on top of the build type ones, the flavors ones, and the default config ones.
Return the merged res values for the variant. This is made of of the variant-specific fields overlayed on top of the build type ones, the flavors ones, and the default config ones.
Return the minSdkVersion for this variant. This uses both the value from the manifest (if present), and the override coming from the flavor(s) (if present).
Returns the original application ID before any overrides from flavors. If the variant is a test variant, then the application ID is the one coming from the configuration of the tested variant, and this call is similar to getApplicationId()
Reads the package name from the manifest. This is unmodified by the build type.
Returns the list of packaged jars for this config. If the config tests a library, this will include the jars of the tested config
Returns the product flavors. Items earlier in the list override later items.
Returns the proguard config files coming from the project but also from the dependencies. Note that if the method is set to include config files coming from libraries, they will only be included if the aars have already been unzipped.
includeLibraries
- whether to include the library dependencies.Returns the list of provided-only jars for this config.
Returns all the renderscript import folder that are outside of the current project.
Returns the renderscript NDK mode.
Returns all the renderscript source folder from the main config, the flavors and the build type.
Returns the renderscript support mode.
Returns a list of generated resource values. Items can be either fields (instance of com.android.builder.model.ClassField) or comments (instance of String).
Returns the dynamic list of com.android.ide.common.res2.ResourceSet based on the configuration, its dependencies, as well as tested config if applicable (test of a library). The list is ordered in ascending order of importance, meaning the first set is meant to be overridden by the 2nd one and so on. This is meant to facilitate usage of the list in a com.android.ide.common.res2.ResourceMerger.
generatedResFolders
- a list of generated res foldersincludeDependencies
- whether to include in the result the resources of the dependenciesReturns a list of sorted SourceProvider in order of ascending order, meaning, the earlier items are meant to be overridden by later items.
Return the targetSdkVersion for this variant. This uses both the value from the manifest (if present), and the override coming from the flavor(s) (if present).
Returns the variant specific source provider
Returns the version code for this variant. This could be coming from the manifest or could be overridden through the product flavors, and can have a suffix specified by the build type.
Reads the version code from the manifest.
Returns the version name for this variant. This could be coming from the manifest or could be overridden through the product flavors, and can have a suffix specified by the build type.
Reads the version name from the manifest.
Sets the dependencies
container
- a DependencyContainer.Sets the variant-specific source provider.
sourceProvider
- the source provider for the product flavorSets the output of this variant. This is required when the variant is a library so that the variant that tests this library can properly include the tested library in its own package.
output
- the output of the library as an LibraryDependency that will provides the
location of all the created items.Sets the variant-specific source provider.
sourceProvider
- the source provider for the product flavor