LibraryExtension

Added in 4.2.0

interface LibraryExtension : CommonExtension, TestedExtension


Extension for the Android Library Gradle Plugin.

This is the android block when the com.android.library plugin is applied.

Only the Android Gradle Plugin should create instances of interfaces in com.android.build.api.dsl.

Summary

Public functions

Unit
aaptOptions(action: AaptOptions.() -> Unit)

This function is deprecated. Replaced by

Unit
adbOptions(action: AdbOptions.() -> Unit)

This function is deprecated. Replaced by installation

Unit

Specifies options related to the processing of Android Resources.

Unit

A list of build features that can be enabled or disabled on the Android Project.

Unit

Encapsulates all build type configurations for this project.

Unit

Specifies Java compiler options, such as the language level of the Java source code and generated bytecode.

Unit
Unit
dataBinding(action: DataBinding.() -> Unit)

Specifies options for the Data Binding Library.

Unit

Shortcut extension method to allow easy access to the predefined debug LibraryBuildType

Unit

Specifies defaults for variant properties that the Android plugin applies to all build variants.

Unit

Specifies options for external native build using CMake or ndk-build.

Unit

Specifies options for the Android Debug Bridge (ADB), such as APK installation options.

Unit

This function is deprecated. Renamed to testCoverage

Unit
lint(action: Lint.() -> Unit)

Specifies options for the lint tool.

Unit

This function is deprecated. Renamed to lint

Unit
packaging(action: 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

Encapsulates all product flavors configurations for this project.

Unit

Customizes publishing build variant artifacts from library module to a Maven repository.

Unit

Shortcut extension method to allow easy access to the predefined release LibraryBuildType

Unit

Encapsulates signing configurations that you can apply to BuildType and ProductFlavor configurations.

Unit

Encapsulates source set configurations for all variants.

Unit
splits(action: Splits.() -> Unit)

Specifies configurations for building multiple APKs or APK splits.

Unit

Configure the gathering of code-coverage from tests.

Unit
testOptions(action: TestOptions.() -> Unit)

Specifies options for how the Android plugin should run local and instrumented tests.

Unit
viewBinding(action: 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

MutableCollection<String>?

Aidl files to package in the aar.

LibraryAndroidResources

Specifies options related to the processing of Android Resources.

LibraryBuildFeatures

A list of build features that can be enabled or disabled on the Android Project.

NamedDomainObjectContainer<LibraryBuildType>

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.

ComposeOptions
DataBinding

Specifies options for the Data Binding Library.

LibraryDefaultConfig

Specifies defaults for variant properties that the Android plugin applies to all build variants.

ExternalNativeBuild

Specifies options for external native build using CMake or ndk-build.

LibraryInstallation

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

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<Prefab>

container of Prefab options

NamedDomainObjectContainer<LibraryProductFlavor>

Encapsulates all product flavors configurations for this project.

LibraryPublishing

Customizes publishing build variant artifacts from library module to a Maven repository.

NamedDomainObjectContainer<ApkSigningConfig>

Encapsulates signing configurations that you can apply to [ ] and [ ] configurations.

NamedDomainObjectContainer<AndroidLibrarySourceSet>

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.

Inherited functions

From com.android.build.api.dsl.CommonExtension
Unit
buildToolsVersion(buildToolsVersion: String)

This function is deprecated. Replaced by buildToolsVersion property

Unit

Configures all aspects regarding compile Sdk version, see CompileSdkSpec for more details.

Unit
compileSdkAddon(vendor: String, name: String, version: Int)

Specify an SDK add-on to compile your project against.

Unit

This function is deprecated. Will be removed in AGP 10.0, replaced by the compileSdk block

Unit

This function is deprecated. Will be removed in AGP 10.0, replaced by the compileSdk block

File
Unit

Includes the specified library to the classpath.

Unit
useLibrary(name: String, required: Boolean)

Includes the specified library to the classpath.

From org.gradle.api.plugins.ExtensionAware
From com.android.build.api.dsl.TestedExtension
Unit

Options to configure the test fixtures.

Inherited properties

From com.android.build.api.dsl.CommonExtension
String

Specifies the version of the SDK Build Tools to use when building your project.

Int?

Specifies the API level to compile your project against.

Int?

Specifies the SDK Extension level to compile your project against.

Int?

Specify a minor API version for the compile SDK.

String?

Specify a preview API to compile your project against.

Boolean

Enables the compilation of Kotlin sources.

MutableMap<String, Any>

Additional per module experimental properties.

MutableList<String>

Specifies the names of product flavor dimensions for this project.

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.

String?

Specifies a resource name prefix required for all resources defined in this module.

SdkComponents
From com.android.build.api.dsl.TestedExtension
String

Specifies the build type that the plugin should use to test the module.

TestFixtures

Options to configure the test fixtures.

String?

The namespace used by the android test and unit test components for the generated R and BuildConfig classes.

Public functions

aaptOptions

fun aaptOptions(action: 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

fun adbOptions(action: 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

Added in 9.6.0-alpha01
fun androidResources(action: LibraryAndroidResources.() -> Unit): Unit

Specifies options related to the processing of Android Resources.

For more information about the properties you can configure in this block, see LibraryAndroidResources.

buildFeatures

Added in 9.6.0-alpha01
fun buildFeatures(action: LibraryBuildFeatures.() -> Unit): Unit

A list of build features that can be enabled or disabled on the Android Project.

buildTypes

Added in 9.6.0-alpha01
@HiddenInDefinition
fun buildTypes(action: NamedDomainObjectContainer<LibraryBuildType>.() -> Unit): Unit

Encapsulates all build type configurations for this project.

For more information about the properties you can configure in this block, see LibraryBuildType

compileOptions

fun compileOptions(action: 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.

composeOptions

fun composeOptions(action: ComposeOptions.() -> Unit): Unit

dataBinding

fun dataBinding(action: 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

Added in 9.6.0-alpha01
fun NamedDomainObjectContainer<LibraryBuildType>.debug(action: LibraryBuildType.() -> Unit): Unit

Shortcut extension method to allow easy access to the predefined debug LibraryBuildType

For example:

 android {
buildTypes {
debug {
// ...
}
}
}

defaultConfig

Added in 9.6.0-alpha01
fun defaultConfig(action: LibraryDefaultConfig.() -> 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 LibraryDefaultConfig.

externalNativeBuild

fun externalNativeBuild(action: 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

Added in 9.6.0-alpha01
fun installation(action: LibraryInstallation.() -> 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
fun jacoco(action: JacocoOptions.() -> Unit): Unit

Configure the gathering of code-coverage from tests.

This is replaced by testCoverage.

lint

fun lint(action: 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
fun lintOptions(action: 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: 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

fun packagingOptions(action: 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

Added in 9.6.0-alpha01
@HiddenInDefinition
fun productFlavors(action: NamedDomainObjectContainer<LibraryProductFlavor>.() -> Unit): Unit

Encapsulates all product flavors configurations for this project.

For more information about the properties you can configure in this block, see ProductFlavor

publishing

Added in 7.1.0
fun publishing(action: LibraryPublishing.() -> Unit): Unit

Customizes publishing build variant artifacts from library module to a Maven repository.

For more information about the properties you can configure in this block, see LibraryPublishing

release

Added in 9.6.0-alpha01
fun NamedDomainObjectContainer<LibraryBuildType>.release(
    action: LibraryBuildType.() -> Unit
): Unit

Shortcut extension method to allow easy access to the predefined release LibraryBuildType

For example:

 android {
buildTypes {
release {
// ...
}
}
}

signingConfigs

@HiddenInDefinition
fun signingConfigs(action: 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

Added in 9.6.0-alpha01
@HiddenInDefinition
fun sourceSets(action: NamedDomainObjectContainer<AndroidLibrarySourceSet>.() -> 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: 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: TestCoverage.() -> Unit): Unit

Configure the gathering of code-coverage from tests.

To override the JaCoCo version that