CommonExtension
interface CommonExtension<BuildFeaturesT : BuildFeatures, BuildTypeT : BuildType, DefaultConfigT : DefaultConfig, ProductFlavorT : ProductFlavor, AndroidResourcesT : AndroidResources>
ApplicationExtension |
Extension for the Android Gradle Plugin Application plugin. |
DynamicFeatureExtension |
Extension for the Android Dynamic Feature Gradle Plugin. |
LibraryExtension |
Extension for the Android Library Gradle Plugin. |
TestExtension |
Extension for the Android Test Gradle Plugin. |
Common extension properties for the Android Application. Library and Dynamic Feature Plugins.
Only the Android Gradle Plugin should create instances of this interface.
Summary
Public functions |
|
---|---|
Unit |
This function is deprecated. Replaced by |
Unit |
This function is deprecated. Replaced by installation |
Unit |
androidResources(action: @ExtensionFunctionType AndroidResourcesT.() -> Unit) Specifies options related to the processing of Android Resources. |
Unit |
buildFeatures(action: @ExtensionFunctionType BuildFeaturesT.() -> Unit) A list of build features that can be enabled or disabled on the Android Project. |
Unit |
This function is deprecated. Replaced by buildToolsVersion property |
Unit |
buildTypes(action: @ExtensionFunctionType NamedDomainObjectContainer<BuildTypeT>.() -> Unit) Encapsulates all build type configurations for this project. |
Unit |
compileOptions(action: @ExtensionFunctionType CompileOptions.() -> Unit) Specifies Java compiler options, such as the language level of the Java source code and generated bytecode. |
Unit |
compileSdkAddon(vendor: String, name: String, version: Int) Specify an SDK add-on to compile your project against. |
Unit |
This function is deprecated. Replaced by compileSdk |
Unit |
This function is deprecated. Replaced by compileSdkPreview |
Unit |
composeOptions(action: @ExtensionFunctionType ComposeOptions.() -> Unit) |
Unit |
dataBinding(action: @ExtensionFunctionType DataBinding.() -> Unit) Specifies options for the Data Binding Library. |
Unit |
NamedDomainObjectContainer<BuildTypeT>.debug( Shortcut extension method to allow easy access to the predefined |
Unit |
defaultConfig(action: @ExtensionFunctionType DefaultConfigT.() -> Unit) Specifies defaults for variant properties that the Android plugin applies to all build variants. |
Unit |
externalNativeBuild(action: @ExtensionFunctionType ExternalNativeBuild.() -> Unit) Specifies options for external native build using CMake or ndk-build. |
Unit |
This function is deprecated. Replaced by flavorDimensions property |
File |
getDefaultProguardFile(name: String) |
Unit |
installation(action: @ExtensionFunctionType Installation.() -> Unit) Specifies options for the Android Debug Bridge (ADB), such as APK installation options. |
@Incubating Unit |
This function is deprecated. Renamed to testCoverage |
Unit |
lint(action: @ExtensionFunctionType Lint.() -> Unit) Specifies options for the lint tool. |
@Incubating Unit |
This function is deprecated. Renamed to lint |
Unit |
packaging(action: @ExtensionFunctionType Packaging.() -> Unit) Specifies options and rules that determine which files the Android plugin packages into your APK. |
Unit |
This function is deprecated. Renamed to packaging |
Unit |
productFlavors(action: @ExtensionFunctionType NamedDomainObjectContainer<ProductFlavorT>.() -> Unit) Encapsulates all product flavors configurations for this project. |
Unit |
NamedDomainObjectContainer<BuildTypeT>.release( Shortcut extension method to allow easy access to the predefined |
Unit |
signingConfigs(action: @ExtensionFunctionType NamedDomainObjectContainer<ApkSigningConfig>.() -> Unit) Encapsulates signing configurations that you can apply to |
Unit |
sourceSets(action: @ExtensionFunctionType NamedDomainObjectContainer<AndroidSourceSet>.() -> Unit) Encapsulates source set configurations for all variants. |
Unit |
splits(action: @ExtensionFunctionType Splits.() -> Unit) Specifies configurations for building multiple APKs or APK splits. |
Unit |
testCoverage(action: @ExtensionFunctionType TestCoverage.() -> Unit) Configure the gathering of code-coverage from tests. |
@Incubating Unit |
testOptions(action: @ExtensionFunctionType TestOptions.() -> Unit) Specifies options for how the Android plugin should run local and instrumented tests. |
Unit |
useLibrary(name: String) Includes the specified library to the classpath. |
Unit |
useLibrary(name: String, required: Boolean) Includes the specified library to the classpath. |
Unit |
viewBinding(action: @ExtensionFunctionType ViewBinding.() -> Unit) Specifies options for the View Binding Library. |
Public properties |
|
---|---|
AaptOptions |
This property is deprecated. Replaced by |
AdbOptions |
This property is deprecated. Replaced by installation |
AndroidResourcesT |
Specifies options related to the processing of Android Resources. |
BuildFeaturesT |
A list of build features that can be enabled or disabled on the Android Project. |
String |
Specifies the version of the SDK Build Tools to use when building your project. |
NamedDomainObjectContainer<BuildTypeT> |
Encapsulates all build type configurations for this project. |
CompileOptions |
Specifies Java compiler options, such as the language level of the Java source code and generated bytecode. |
Int? |
Specifies the API level to compile your project against. |
Int? |
Specifies the SDK Extension level to compile your project against. |
String? |
Specify a preview API to compile your project against. |
ComposeOptions |
|
DataBinding |
Specifies options for the Data Binding Library. |
DefaultConfigT |
Specifies defaults for variant properties that the Android plugin applies to all build variants. |
MutableMap<String, Any> |
Additional per module experimental properties. |
ExternalNativeBuild |
Specifies options for external native build using CMake or ndk-build. |
MutableList<String> |
Specifies the names of product flavor dimensions for this project. |
Installation |
Specifies options for the Android Debug Bridge (ADB), such as APK installation options. |
JacocoOptions |
This property is deprecated. Renamed to testCoverage |
Lint |
Specifies options for the lint tool. |
LintOptions |
This property is deprecated. Renamed to lint |
String? |
The namespace of the generated R and BuildConfig classes. |
String? |
Requires the specified path to NDK be used. |
String |
Requires the specified NDK version to be used. |
Packaging |
Specifies options and rules that determine which files the Android plugin packages into your APK. |
Packaging |
This property is deprecated. Renamed to packaging |
NamedDomainObjectContainer<ProductFlavorT> |
Encapsulates all product flavors configurations for this project. |
String? |
Specifies this project's resource prefix to Android Studio for editor features, such as Lint checks. |
SdkComponents |
This property is deprecated. This API will be removed in AGP 7.0, replaced with AndroidComponents::sdkComponents |
NamedDomainObjectContainer<ApkSigningConfig> |
Encapsulates signing configurations that you can apply to [ ] and [ ] configurations. |
NamedDomainObjectContainer<AndroidSourceSet> |
Encapsulates source set configurations for all variants. |
Splits |
Specifies configurations for building multiple APKs or APK splits. |
TestCoverage |
Configure the gathering of code-coverage from tests. |
TestOptions |
Specifies options for how the Android plugin should run local and instrumented tests. |
ViewBinding |
Specifies options for the View Binding Library. |
Public functions
aaptOptions
funaaptOptions(action: @ExtensionFunctionType AaptOptions.() -> Unit): Unit
Specifies options for the Android Asset Packaging Tool (AAPT).
For more information about the properties you can configure in this block, see AaptOptions
.
adbOptions
funadbOptions(action: @ExtensionFunctionType AdbOptions.() -> Unit): Unit
Specifies options for the Android Debug Bridge (ADB), such as APK installation options.
For more information about the properties you can configure in this block, see AdbOptions
.
androidResources
fun androidResources(action: @ExtensionFunctionType AndroidResourcesT.() -> Unit): Unit
Specifies options related to the processing of Android Resources.
For more information about the properties you can configure in this block, see AndroidResources
.
buildFeatures
fun buildFeatures(action: @ExtensionFunctionType BuildFeaturesT.() -> Unit): Unit
A list of build features that can be enabled or disabled on the Android Project.
buildTypes
fun buildTypes(action: @ExtensionFunctionType NamedDomainObjectContainer<BuildTypeT>.() -> Unit): Unit
Encapsulates all build type configurations for this project.
For more information about the properties you can configure in this block, see BuildType
compileOptions
fun compileOptions(action: @ExtensionFunctionType CompileOptions.() -> Unit): Unit
Specifies Java compiler options, such as the language level of the Java source code and generated bytecode.
For more information about the properties you can configure in this block, see CompileOptions
.
compileSdkAddon
fun compileSdkAddon(vendor: String, name: String, version: Int): Unit
Specify an SDK add-on to compile your project against.
This can be set on all Gradle projects with com.android.build.api.dsl.SettingsExtension.compileSdkAddon
dataBinding
fun dataBinding(action: @ExtensionFunctionType DataBinding.() -> Unit): Unit
Specifies options for the Data Binding Library.
For more information about the properties you can configure in this block, see DataBinding
debug
fun NamedDomainObjectContainer<BuildTypeT>.debug(
action: @ExtensionFunctionType BuildTypeT.() -> Unit
): Unit
Shortcut extension method to allow easy access to the predefined debug
BuildType
For example:
android {
buildTypes {
debug {
// ...
}
}
}
defaultConfig
fun defaultConfig(action: @ExtensionFunctionType DefaultConfigT.() -> Unit): Unit
Specifies defaults for variant properties that the Android plugin applies to all build variants.
You can override any defaultConfig
property when configuring product flavors
For more information about the properties you can configure in this block, see DefaultConfig
.
externalNativeBuild
fun externalNativeBuild(action: @ExtensionFunctionType ExternalNativeBuild.() -> Unit): Unit
Specifies options for external native build using CMake or ndk-build.
When using Android Studio 2.2 or higher with Android plugin 2.2.0 or higher, you can compile C and C++ code into a native library that Gradle packages into your APK.
To learn more, read Add C and C++ Code to Your Project.
See also | |
---|---|
ExternalNativeBuild |
since 2.2.0 |
installation
fun installation(action: @ExtensionFunctionType Installation.() -> Unit): Unit
Specifies options for the Android Debug Bridge (ADB), such as APK installation options.
For more information about the properties you can configure in this block, see AdbOptions
.
jacoco
@Incubating
funjacoco(action: @ExtensionFunctionType JacocoOptions.() -> Unit): Unit
Configure the gathering of code-coverage from tests.
This is replaced by testCoverage
.
lint
fun lint(action: @ExtensionFunctionType Lint.() -> Unit): Unit
Specifies options for the lint tool.
For more information about the properties you can configure in this block, see Lint
.
lintOptions
@Incubating
funlintOptions(action: @ExtensionFunctionType LintOptions.() -> Unit): Unit
Specifies options for the lint tool.
For more information about the properties you can configure in this block, see LintOptions
.
packaging
fun packaging(action: @ExtensionFunctionType Packaging.() -> Unit): Unit
Specifies options and rules that determine which files the Android plugin packages into your APK.
For more information about the properties you can configure in this block, see Packaging
.
packagingOptions
funpackagingOptions(action: @ExtensionFunctionType Packaging.() -> Unit): Unit
Specifies options and rules that determine which files the Android plugin packages into your APK.
For more information about the properties you can configure in this block, see Packaging
.
productFlavors
fun productFlavors(action: @ExtensionFunctionType NamedDomainObjectContainer<ProductFlavorT>.() -> Unit): Unit
Encapsulates all product flavors configurations for this project.
For more information about the properties you can configure in this block, see ProductFlavor
release
fun NamedDomainObjectContainer<BuildTypeT>.release(
action: @ExtensionFunctionType BuildTypeT.() -> Unit
): Unit
Shortcut extension method to allow easy access to the predefined release
BuildType
For example:
android {
buildTypes {
release {
// ...
}
}
}
signingConfigs
fun signingConfigs(action: @ExtensionFunctionType NamedDomainObjectContainer<ApkSigningConfig>.() -> Unit): Unit
Encapsulates signing configurations that you can apply to BuildType
and ProductFlavor
configurations.
For more information about the properties you can configure in this block, see ApkSigningConfig
.
sourceSets
fun sourceSets(action: @ExtensionFunctionType NamedDomainObjectContainer<AndroidSourceSet>.() -> Unit): Unit
Encapsulates source set configurations for all variants.
Note that the Android plugin uses its own implementation of source sets. For more information about the properties you can configure in this block, see AndroidSourceSet
.
splits
fun splits(action: @ExtensionFunctionType Splits.() -> Unit): Unit
Specifies configurations for building multiple APKs or APK splits.
For more information about the properties you can configure in this block, see Splits
.
testCoverage
fun testCoverage(action: @ExtensionFunctionType TestCoverage.() -> Unit): Unit
Configure the gathering of code-coverage from tests.
To override the JaCoCo version that is used for offline instrumentation and coverage report, add the following to build.gradle
file:
android {
testCoverage {
jacocoVersion "<jacoco-version>"
}
}
For more information about the properties you can configure in this block, see TestCoverage
.
testOptions
@Incubating
fun testOptions(action: @ExtensionFunctionType TestOptions.() -> Unit): Unit
Specifies options for how the Android plugin should run local and instrumented tests.
For more information about the properties you can configure in this block, see TestOptions
.
useLibrary
fun useLibrary(name: String): Unit
Includes the specified library to the classpath.
You typically use this property to support optional platform libraries that ship with the Android SDK. The following sample adds the Apache HTTP API library to the project classpath:
android {
// Adds a platform library that ships with the Android SDK.
useLibrary 'org.apache.http.legacy'
}
To include libraries that do not ship with the SDK, such as local library modules or binaries from remote repositories, add the libraries as dependencies in the dependencies
block. Note that Android plugin 3.0.0 and later introduce new dependency configurations. To learn more about Gradle dependencies, read Dependency Management Basics.
Parameters | |
---|---|
name: String |
the name of the library. |
useLibrary
fun useLibrary(name: String, required: Boolean): Unit
Includes the specified library to the classpath.
You typically use this property to support optional platform libraries that ship with the Android SDK. The following sample adds the Apache HTTP API library to the project classpath:
android {
// Adds a platform library that ships with the Android SDK.
useLibrary 'org.apache.http.legacy'
}
To include libraries that do not ship with the SDK, such as local library modules or binaries from remote repositories, "https://developer.android.com/studio/build/dependencies.html in the dependencies
block. Note that Android plugin 3.0.0 and later introduce new dependency configurations. To learn more about Gradle dependencies, read Dependency Management Basics
viewBinding
fun viewBinding(action: @ExtensionFunctionType ViewBinding.() -> Unit): Unit
Specifies options for the View Binding Library.
For more information about the properties you can configure in this block, see ViewBinding
Public properties
aaptOptions
val aaptOptions: AaptOptions
Specifies options for the Android Asset Packaging Tool (AAPT).
For more information about the properties you can configure in this block, see AaptOptions
.
adbOptions
val adbOptions: AdbOptions
Specifies options for the Android Debug Bridge (ADB), such as APK installation options.
For more information about the properties you can configure in this block, see AdbOptions
.
androidResources
val androidResources: AndroidResourcesT
Specifies options related to the processing of Android Resources.
For more information about the properties you can configure in this block, see AndroidResources
.
buildFeatures
val buildFeatures: BuildFeaturesT
A list of build features that can be enabled or disabled on the Android Project.
buildToolsVersion
var buildToolsVersion: String
Specifies the version of the SDK Build Tools to use when building your project.
When using Android plugin 3.0.0 or later, configuring this property is optional. By default, the plugin uses the minimum version of the build tools required by the version of the plugin you're using. To specify a different version of the build tools for the plugin to use, specify the version as follows:
android {
// Specifying this property is optional.
buildToolsVersion "26.0.0"
}
For a list of build tools releases, read the release notes.
Note that the value assigned to this property is parsed and stored in a normalized form, so reading it back may give a slightly different result.
This can be set on all Gradle projects with com.android.build.api.dsl.SettingsExtension.buildToolsVersion
buildTypes
val buildTypes: NamedDomainObjectContainer<BuildTypeT>
Encapsulates all build type configurations for this project.
Unlike using ProductFlavor
to create different versions of your project that you expect to co-exist on a single device, build types determine how Gradle builds and packages each version of your project. Developers typically use them to configure projects for various stages of a development lifecycle. For example, when creating a new project from Android Studio, the Android plugin configures a 'debug' and 'release' build type for you. By default, the 'debug' build type enables debugging options and signs your APK with a generic debug keystore. Conversely, The 'release' build type strips out debug symbols and requires you to create a release key and keystore for your app. You can then combine build types with product flavors to create build variants.
See also | |
---|---|
BuildType |
compileOptions
val compileOptions: CompileOptions
Specifies Java compiler options, such as the language level of the Java source code and generated bytecode.
For more information about the properties you can configure in this block, see CompileOptions
.
compileSdk
var compileSdk: Int?
Specifies the API level to compile your project against. The Android plugin requires you to configure this property.
This means your code can use only the Android APIs included in that API level and lower. You can configure the compile sdk version by adding the following to the android
block: compileSdk = 26
.
You should generally use the most up-to-date API level available. If you are planning to also support older API levels, it's good practice to use the Lint tool to check if you are using APIs that are not available in earlier API levels.
The value you assign to this property is parsed and stored in a normalized form, so reading it back may return a slightly different value.
This can be set on all Gradle projects with com.android.build.api.dsl.SettingsExtension.compileSdk
compileSdkExtension
var compileSdkExtension: Int?
Specifies the SDK Extension level to compile your project against. This value is optional.
When not provided the base extension for the given compileSdk
API level will be selected.
This can be set on all Gradle projects with com.android.build.api.dsl.SettingsExtension.compileSdkExtension
compileSdkPreview
var compileSdkPreview: String?
Specify a preview API to compile your project against.
For example, to try out the Android S preview, rather than compileSdk = 30
you can use compileSdkPreview = "S"
Once the preview APIs are finalized, they will be allocated a stable integer value.
This can be set on all Gradle projects with com.android.build.api.dsl.SettingsExtension.compileSdkPreview
dataBinding
val dataBinding: DataBinding
Specifies options for the Data Binding Library.
For more information about the properties you can configure in this block, see DataBinding
defaultConfig
val defaultConfig: DefaultConfigT
Specifies defaults for variant properties that the Android plugin applies to all build variants.
You can override any defaultConfig
property when configuring product flavors
For more information about the properties you can configure in this block, see DefaultConfig
.
experimentalProperties
val experimentalProperties: MutableMap<String, Any>
Additional per module experimental properties.
externalNativeBuild
val externalNativeBuild: ExternalNativeBuild
Specifies options for external native build using CMake or ndk-build.
When using Android Studio 2.2 or higher with Android plugin 2.2.0 or higher, you can compile C and C++ code into a native library that Gradle packages into your APK.
To learn more, read Add C and C++ Code to Your Project.
See also | |
---|---|
ExternalNativeBuild |
since 2.2.0 |
flavorDimensions
val flavorDimensions: MutableList<String>
Specifies the names of product flavor dimensions for this project.
When configuring product flavors with Android plugin 3.0.0 and higher, you must specify at least one flavor dimension, using the
property, and then assign each flavor to a dimension. Otherwise, you will get the following build error:flavorDimensions
Error:All flavors must now belong to a named flavor dimension.
The flavor 'flavor_name' is not assigned to a flavor dimension.
By default, when you specify only one dimension, all flavors you configure automatically belong to that dimension. If you specify more than one dimension, you need to manually assign each flavor to a dimension, as shown in the sample below.
Flavor dimensions allow you to create groups of product flavors that you can combine with flavors from other flavor dimensions. For example, you can have one dimension that includes a 'free' and 'paid' version of your app, and another dimension for flavors that support different API levels, such as 'minApi21' and 'minApi24'. The Android plugin can then combine flavors from these dimensions—including their settings, code, and resources—to create variants such as 'debugFreeMinApi21' and 'releasePaidMinApi24', and so on. The sample below shows you how to specify flavor dimensions and add product flavors to them.
android {
...
// Specifies the flavor dimensions you want to use. The order in which you
// list each dimension determines its priority, from highest to lowest,
// when Gradle merges variant sources and configurations. You must assign
// each product flavor you configure to one of the flavor dimensions.
flavorDimensions 'api', 'version'
productFlavors {
demo {
// Assigns this product flavor to the 'version' flavor dimension.
dimension 'version'
...
}
full {
dimension 'version'
...
}
minApi24 {
// Assigns this flavor to the 'api' dimension.
dimension 'api'
minSdkVersion '24'
versionNameSuffix "-minApi24"
...
}
minApi21 {
dimension "api"
minSdkVersion '21'
versionNameSuffix "-minApi21"
...
}
}
}
To learn more, read Combine multiple flavors.
installation
val installation: Installation
Specifies options for the Android Debug Bridge (ADB), such as APK installation options.
For more information about the properties you can configure in this block, see AdbOptions
.
jacoco
val jacoco: JacocoOptions
Configure the gathering of code-coverage from tests.
This is replaced by testCoverage
.
lint
val lint: Lint
Specifies options for the lint tool.
For more information about the properties you can configure in this block, see Lint
.
lintOptions
val lintOptions: LintOptions
Specifies options for the lint tool.
For more information about the properties you can configure in this block, see LintOptions
.
namespace
var namespace: String?
The namespace of the generated R and BuildConfig classes. Also, the namespace used to resolve any relative class names that are declared in the AndroidManifest.xml.
ndkPath
var ndkPath: String?
Requires the specified path to NDK be used.
Use this to specify a path to the NDK folder to be used for C and C++ builds.
android {
// Path to custom NDK location
ndkPath '/path/to/ndk'
}
If this field is specified, then the version it refers to need to match the one specified in ndkVersion. If ndkVersion is not specified, ndkPath need to match the default ndkVersion
For additional information about NDK installation see Install and configure the NDK.
This can be set on all Gradle projects with com.android.build.api.dsl.SettingsExtension.ndkPath
ndkVersion
var ndkVersion: String
Requires the specified NDK version to be used.
Use this to specify a fixed NDK version. Without this, each new version of the Android Gradle Plugin will choose a specific version of NDK to use, so upgrading the plugin also means upgrading the NDK. Locking to a specific version can increase repeatability of the build.
android {
// Use a fixed NDK version
ndkVersion '20.1.5948944'
}
If this field is specified then android.ndkPath may not be specified. If this field is not specified, a default value will be provided depending on the AGP version
The required format of the version is major.minor.build
. It's not legal to specify less precision. If ndk.dir
is specified in local.properties
file then the NDK that it points to must match the android.ndkVersion
.
Prior to Android Gradle Plugin version 3.5, the highest installed version of NDK will be used. In Android Gradle Plugin 3.4, specifying android.ndkVersion
was not an error, but the value would be ignored. Prior to Android Gradle Plugin version 3.4, it was illegal to specify android.ndkVersion
.
For additional information about NDK installation see Install and configure the NDK.
This can be set on all Gradle projects with com.android.build.api.dsl.SettingsExtension.ndkVersion
packaging
val packaging: Packaging
Specifies options and rules that determine which files the Android plugin packages into your APK.
For more information about the properties you can configure in this block, see Packaging
.
packagingOptions
val packagingOptions: Packaging
Specifies options and rules that determine which files the Android plugin packages into your APK.
For more information about the properties you can configure in this block, see Packaging
.
productFlavors
val productFlavors: NamedDomainObjectContainer<ProductFlavorT>
Encapsulates all product flavors configurations for this project.
Product flavors represent different versions of your project that you expect to co-exist on a single device, the Google Play store, or repository. For example, you can configure 'demo' and 'full' product flavors for your app, and each of those flavors can specify different features, device requirements, resources, and application ID's--while sharing common source code and resources. So, product flavors allow you to output different versions of your project by simply changing only the components and settings that are different between them.
Configuring product flavors is similar to configuring build types: add them to the productFlavors
block of your project's build.gradle
file and configure the settings you want. Product flavors support the same properties as the defaultConfig
block--this is because defaultConfig
defines an object that the plugin uses as the base configuration for all other flavors. Each flavor you configure can then override any of the default values in defaultConfig
, such as the applicationId
.
When using Android plugin 3.0.0 and higher, each flavor must belong to a com.android.build.gradle.BaseExtension.html#com.android.build.gradle.BaseExtension:flavorDimensions(java.lang.String[]) value. By default, when you specify only one dimension, all flavors you configure belong to that dimension. If you specify more than one flavor dimension, you need to manually assign each flavor to a dimension. To learn more, read Use Flavor Dimensions for variant-aware dependency management.
When you configure product flavors, the Android plugin automatically combines them with your BuildType
configurations to create build variants. If the plugin creates certain build variants that you don't want, you can filter variants.
See also | |
---|---|
ProductFlavor |
resourcePrefix
var resourcePrefix: String?
Specifies this project's resource prefix to Android Studio for editor features, such as Lint checks. This property is useful only when using Android Studio.
Including unique prefixes for project resources helps avoid naming collisions with resources from other projects.
For example, when creating a library with String resources, you may want to name each resource with a unique prefix, such as "mylib_
" to avoid naming collisions with similar resources that the consumer defines.
You can then specify this prefix, as shown below, so that Android Studio expects this prefix when you name project resources:
// This property is useful only when developing your project in Android Studio.
resourcePrefix 'mylib_'
signingConfigs
val signingConfigs: NamedDomainObjectContainer<ApkSigningConfig>
Encapsulates signing configurations that you can apply to [ ] and [ ] configurations.
Android requires that all APKs be digitally signed with a certificate before they can be installed onto a device. When deploying a debug version of your project from Android Studio, the Android plugin automatically signs your APK with a generic debug certificate. However, to build an APK for release, you must sign the APK with a release key and keystore. You can do this by either using the Android Studio UI or manually configuring your build.gradle
file.
See also | |
---|---|
ApkSigningConfig |
sourceSets
val sourceSets: NamedDomainObjectContainer<AndroidSourceSet>
Encapsulates source set configurations for all variants.
Note that the Android plugin uses its own implementation of source sets. For more information about the properties you can configure in this block, see AndroidSourceSet
.
splits
val splits: Splits
Specifies configurations for building multiple APKs or APK splits.
For more information about the properties you can configure in this block, see Splits
.
testCoverage
val testCoverage: TestCoverage
Configure the gathering of code-coverage from tests.
To override the JaCoCo version that is used for offline instrumentation and coverage report, add the following to build.gradle
file:
android {
testCoverage {
jacocoVersion "<jacoco-version>"
}
}
For more information about the properties you can configure in this block, see TestCoverage
.
testOptions
val testOptions: TestOptions
Specifies options for how the Android plugin should run local and instrumented tests.
For more information about the properties you can configure in this block, see TestOptions
.
viewBinding
val viewBinding: ViewBinding
Specifies options for the View Binding Library.
For more information about the properties you can configure in this block, see ViewBinding