Android Plugin DSL Reference

Version 1.2.3

Introduction

This is the DSL reference for Android Gradle Plugin.

Android configuration structure

BlockDescription
aaptOptions { }

Configures aapt options.

buildTypes { }

Configures the build types.

compileOptions { }

Configures compile options.

defaultConfig { }

The default configuration, inherited by all build flavors (if any are defined).

dexOptions { }

Configures dex options.

jacoco { }

Configures JaCoCo options.

lintOptions { }

Configure lint options.

packagingOptions { }

Configures packaging options.

productFlavors { }

Configures the product flavors.

signingConfigs { }

Configures the signing configs.

sourceSets { }

Configures the source sets. Note that the Android plugin uses its own implementation of source sets, AndroidSourceSet.

splits { }

Configures APK splits.

testOptions { }

Configures the test options.

DSL types

Listed below are some of the central types which are used in the Android plugin:

TypeDescription
BaseExtension

Base 'android' extension for all android plugins.

TestedExtension

base 'android' extension for plugins that have a test component.

AppExtension

Options for com.android.application projects.

LibraryExtension

Options for com.android.library projects.

TestExtension

'android' extension for 'com.android.test' project.

AndroidSourceSet

An AndroidSourceSet represents a logical group of Java, aidl and RenderScript sources as well as Android and non-Android (Java-style) resources.

AndroidSourceDirectorySet

An AndroidSourceDirectorySet represents a lit of directory input for an Android project.

AndroidSourceFile

An AndroidSourceFile represents a single file input for an Android project.

BuildType

DSL object to configure build types.

SigningConfig

DSL object for configuring signing configs.

TestOptions

Options for running tests.

AaptOptions

DSL object for configuring aapt options.

LintOptions

DSL object for configuring lint options.

DexOptions

DSL object for configuring dx options.

CompileOptions

Compilation options.

GroupableProductFlavor

A version of ProductFlavor that can receive a dimension name.

JacocoExtension

DSL object for configuring JaCoCo settings.

PackagingOptions

DSL objects for configuring APK packaging options.

ProductFlavor

DSL object used to configure product flavors.

Splits

DSL object for configuring APK Splits options.

VariantFilter

Exposes a read-only view of a variant as well as a flag that can be used to signal that the variant should be ignored.