Android Plugin DSL Reference

Version 1.1.1

Introduction

This is the DSL reference for Android Gradle Plugin.

Android configuration structure

BlockDescription
defaultConfig { }

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

sourceSets { }

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

buildTypes { }

Configures the build types.

signingConfigs { }

Configures the signing configs.

productFlavors { }

Configures the product flavors.

testOptions { }

Configures the test options.

aaptOptions { }

Configures aapt options.

lintOptions { }

Configure lint options.

dexOptions { }

Configures dex options.

compileOptions { }

Configures compile options.

packagingOptions { }

Configures packaging options.

jacoco { }

Configures JaCoCo options.

splits { }

Configures APK splits.

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.

AppExtension

'android' extension for 'com.android.application' project. This extends BaseExtension

LibraryExtension

'android' extension for 'com.android.library' project. This extends BaseExtension

AndroidSourceSet

A AndroidSourceSet represents a logical group of Java, aidl, renderscript source as well as Android and non-Android resources.

ProductFlavor

DSL object used to configure product flavors.

GroupableProductFlavor

A version of ProductFlavor that can receive a dimension name.

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.

PackagingOptions

DSL objects for configuring APK packaging options.

JacocoExtension

DSL object for configuring JaCoCo settings.

Splits

Main entry point for all splits related information.

VariantFilter

An object representing a Variant (made of a build type and one or more flavors), and a boolean controlling whether this variant is to be excluded.