Android Plugin DSL Reference

Version 1.3.0

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
AppExtension

'android' extension for 'com.android.application' project.

BaseExtension

Base 'android' extension for all android plugins.

LibraryExtension

'android' extension for 'com.android.library' project.

TestExtension

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

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.

AndroidSourceSet

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

CompileOptions

Compilation 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.

JacocoExtension

DSL object for configuring JaCoCo settings.

AaptOptions

DSL object for configuring aapt options.

BuildType

DSL object to configure build types.

DexOptions

DSL object for configuring dx options.

LintOptions

DSL object for configuring lint options.

PackagingOptions

DSL objects for configuring APK packaging options.

ProductFlavor

DSL object used to configure product flavors.

SigningConfig

DSL object for configuring signing configs.

Splits

DSL object for configuring APK Splits options.

UnitTestOptions

Options for controlling unit tests execution.

TestOptions

Options for running tests.