page.title=Android Plugin for Gradle Release Notes @jd:body

See also

  1. Build System Overview
  2. Android Plugin for Gradle

The Android build system uses the Android Plugin for Gradle to support building Android applications with the Gradle build toolkit. The plugin runs independent of Android Studio so the plugin and the Gradle build system can be updated independently of Android Studio.

Note: When you update Android Studio or open a project in a previous version of Android Studio, Android Studio prompts you to automatically update the plugin and Gradle to the latest available versions. You can choose to accept these updates based on your project's build requirements.

Revisions

The sections below provide notes about successive releases of the Android Plugin for Gradle, as denoted by revision number. To determine what revision of the plugin you are using, check the version declaration in the project-level build.gradle file.

For a summary of known issues in Android Plugin for Gradle, see http://tools.android.com/knownissues.

Android Plugin for Gradle, Revision 1.5.0 (November 2015)

Dependencies:
  • Gradle 2.2.1 or higher.
  • Build Tools 21.1.1 or higher.
General Notes:
  • Integrated the Data Binding Plugin into the Android Plugin for Gradle. To enable it, add the following code to each per-project build.gradle file that uses the plugin:
  • android {
        dataBinding {
            enabled = true
        }
    }
    
  • Added a new Transform API to allow third-party plugins to manipulate compiled .class files before they’re converted to .dex files. The Transform API simplifies injecting custom class manipulations while offering more flexibility regarding what you can manipulate. To insert a transform into a build, create a new class implementing one of the Transform interfaces, and register it with android.registerTransform(theTransform) or android.registerTransform(theTransform, dependencies). There’s no need to wire tasks together. Note the following about the Transform API:
    • A transform can apply to one or more of the following: the current project, subprojects, and external libraries.
    • A transform must be registered globally, which applies them to all variants.
    • Internal code processing, through the Java Code Coverage Library (JaCoCo), ProGuard, and MultiDex, now uses the Transform API. However, the Java Android Compiler Kit (Jack) doesn’t use this API: only the javac/dx code path does.
    • Gradle executes the transforms in this order: JaCoCo, third-party plugins, ProGuard. The execution order for third-party plugins matches the order in which the transforms are added by the third party plugins; third-party plugin developers can't control the execution order of the transforms through an API.
  • Deprecated the dex getter from the ApplicationVariant class. You can't access the Dex task through the variant API anymore because it’s now accomplished through a transform. There's currently no replacement for controlling the dex process.
  • Fixed incremental support for assets.
  • Improved MultiDex support by making it available for test projects, and tests now automatically have the com.android.support:multidex-instrumentation dependency.
  • Added the ability to properly fail a Gradle build and report the underlying error cause when the Gradle build invokes asynchronous tasks and there’s a failure in the worker process.
  • Added support for configuring a specific Application Binary Interface (ABI) in variants that contain multiple ABIs.
  • Added support for a comma-separated list of device serial numbers for the ANDROID_SERIAL environment variable when installing or running tests.
  • Fixed an installation failure on devices running Android 5.0 (API level 20) and higher when the APK name contains a space.
  • Fixed various issues related to the Android Asset Packaging Tool (AAPT) error output.
  • Added JaCoCo incremental instrumentation support for faster incremental builds. The Android Plugin for Gradle now invokes the JaCoCo instrumenter directly. To force a newer version of the JaCoCo instrumenter, you need to add it as a build script dependency.
  • Fixed JaCoCo support so it ignores files that aren’t classes.
  • Added vector drawable support for generating PNGs at build time for backward-compatibility. Android Plugin for Gradle generates PNGs for every vector drawable found in a resource directory that doesn’t specify an API version or specifies an android:minSdkVersion attribute of 20 or lower in the <uses-sdk> element in the app manifest. You can set PNG densities by using the generatedDensities property in the defaultConfig or productFlavor sections of a build.gradle file.
  • Added sharing of the mockable android.jar, which the plugin generates only once and uses for unit testing. Multiple modules, such as app and lib, now share it. Delete $rootDir/build to regenerate it.
  • Changed the processing of Java resources to occur before the obfuscation tasks instead of during the packaging of the APK. This change allows the obfuscation tasks to have a chance to adapt the Java resources following packages obfuscation.
  • Fixed an issue with using Java Native Interface (JNI) code in the experimental library plugin.
  • Added the ability to set the platform version separately from the android:compileSdkVersion attribute in the experimental library plugin.

Android Plugin for Gradle, Revision 1.3.1 (August 2015)

Dependencies:
  • Gradle 2.2.1 or higher.
  • Build Tools 21.1.1 or higher.
General Notes:
  • Fixed the ZipAlign task to properly consume the output of the previous task when using a customized filename.
  • Fixed Renderscript packaging with the NDK.
  • Maintained support for the createDebugCoverageReport build task.
  • Fixed support for customized use of the archiveBaseName property in the build.gradle build> file.
  • Fixed the Invalid ResourceType lint warning caused by parameter method annotation lookup when running lint outside of Android Studio.

Android Plugin for Gradle, Revision 1.3.0 (July 2015)

Dependencies:
  • Gradle 2.2.1 or higher.
  • Build Tools 21.1.1 or higher.
General Notes:
  • Added support for the com.android.build.threadPoolSize property to control the Android task thread pool size from the gradle.properties file or the command line. The following example sets this property to 4.
    -Pcom.android.build.threadPoolSize=4
    
  • Set the default build behavior to exclude LICENSE and LICENSE.txt files from APKs. To include these files in an APK, remove these files from the packagingOptions.excludes property in the build.gradle file. For example:
    android {
          packagingOptions.excludes = []
        }
    
  • Added the sourceSets task to inspect the set of all available source sets.
  • Enhanced unit test support to recognize multi-flavor and build variant source folders. For example, to test an app with multi-flavors flavor1 and flavorA with the Debug build type, the test source sets are:
    • test
    • testFlavor1
    • testFlavorA
    • testFlavor1FlavorA
    • testFlavor1FlavorADebug

    Android tests already recognized multi-flavor source folders.

  • Improved unit test support to:

    • Run javac on main and test sources, even if the useJack property is set to true in your build file.
    • Correctly recognize dependencies for each build type.
  • Added support for specifying instrumentation test-runner arguments from the command line. For example:
    ./gradlew connectedCheck \
       -Pandroid.testInstrumentationRunnerArguments.size=medium \
       -Pandroid.testInstrumentationRunnerArguments.class=TestA,TestB
    
  • Added support for arbitrary additional Android Asset Packaging Tool (AAPT) parameters in the build.gradle file. For example:
    android {
        aaptOptions {
          additionalParameters "--custom_option", "value"
        }
    }
    
  • Added support for a test APK module as a separate test module, using the targetProjectPath and targetVariant properties to set the APK path and target variant.

    Note: A test APK module does not support product flavors and can only target a single variant. Also, Jacoco is not supported yet.

  • Added resource name validation before merging resources.
  • When building an AAR (Android ARchive) package for library modules, do not provide an automatic @{applicationId} placeholder in the manifest merger settings. Instead, use a different placeholder, such as @{libApplicationId} and provide a value for it if you want to include application Ids in the archive library.

Android Plugin for Gradle, Revision 1.2.0 (April 2015)

Dependencies:
  • Gradle 2.2.1 or higher.
  • Build Tools 21.1.1 or higher.
General Notes:
  • Enhanced support for running unit tests with Gradle.
    • Added support to include Java-style resources in the classpath when running unit tests directly from Gradle.
    • Added unit test dependency support for Android ARchive (AAR) artifacts.
    • Added support for the unitTestVariants property so unit test variants can be manipulated using the build.gradle file.
    • Added the unitTest.all code block under testOptions to configure customized tasks for unit test. The following sample code shows how to add unit test configuration settings using this new option:
      android {
        testOptions {
          unitTest.all {
            jvmArgs '-XX:MaxPermSize=256m' // Or any other gradle option.
          }
        }
      }
      
    • Fixed the handling of enums and public instance fields in the packaging of the mockable-android.jar file.
    • Fixed library project task dependencies so test classes recompile after changes.
  • Added the testProguardFile property to apply ProGuard files when minifying a test APK.
  • Added the timeOut property to the adbOptions code block for setting the maximum recording time for Android Debug Bridge screen recording.
  • Added support for 280 dpi resources.
  • Improved performance during project evaluation.

Android Plugin for Gradle, Revision 1.1.3 (March 2015)

Dependencies:
  • Gradle 2.2.1 or higher.
  • Build Tools 21.1.1 or higher.
General Notes:
  • Fixed issue with duplicated dependencies on a test app that triggered a ProGuard failure.
  • Fixed Comparator implementation which did not comply with the JDK Comparator contract and generated a JDK 7 error.

Android Plugin for Gradle, Revision 1.1.2 (February 2015)

Dependencies:
  • Gradle 2.2.1 or higher.
  • Build Tools 21.1.1 or higher.
General Notes:
  • Normalized path when creating a mockable JAR for unit testing.
  • Fixed the archivesBaseName setting in the build.gradle file.
  • Fixed the unresolved placeholder failure in manifest merger when building a library test application.

Android Plugin for Gradle, Revision 1.1.1 (February 2015)

Dependencies:
  • Gradle 2.2.1 or higher.
  • Build Tools 21.1.1 or higher.
General Notes:
  • Modified build variants so only variants that package a Wear app trigger Wear-specific build tasks.
  • Changed dependency related issues to fail at build time rather than at debug time. This behavior allows you to run diagnostic diagnostic tasks (such as 'dependencies') to help resolve the conflict.
  • Fixed the android.getBootClasspath() method to return a value.

Android Plugin for Gradle, Revision 1.1.0 (February 2015)

Dependencies:
  • Gradle 2.2.1 or higher.
  • Build Tools 21.1.1 or higher.
General Notes:
  • Added new unit test support
    • Enabled unit tests to run on the local JVM against a special version of the android.jar file that is compatible with popular mocking frameworks, for example Mockito.
    • Added new test tasks testDebug, testRelease, and testMyFlavorDebug when using product flavors.
    • Added new source folders recognized as unit tests: src/test/java/, src/testDebug/java/, src/testMyFlavor/java/.
    • Added new configurations in the build.gradle file for declaring test-only dependencies, for example, testCompile 'junit:junit:4.11', testMyFlavorCompile 'some:library:1.0'.

      Note: Test-only dependencies are not currently compatible with Jack (Java Android Compiler Kit).

    • Added the android.testOptions.unitTests.returnDefaultValues option to control the behaviour of the mockable android.jar.
  • Replaced Test in test task names with AndroidTest. For example, the assembleDebugTest task is now assembleDebugAndroidTest task. Unit test tasks still have UnitTest in the task name, for example assembleDebugUnitTest.
  • Modified ProGuard configuration files to no longer apply to the test APK. If minification is enabled, ProGuard processes the test APK and applies only the mapping file that is generated when minifying the main APK.
  • Updated dependency management
    • Fixed issues using provided and package scopes.

      Note: These scopes are incompatible with AAR (Android ARchive) packages and will cause a build with AAR packages to fail.

    • Modified dependency resolution to compare the dependencies of an app under test and the test app. If an artifact with the same version is found for both apps, it's not included with the test app and is packaged only with the app under test. If an artifact with a different version is found for both apps, the build fails.
  • Added support for anyDpi resource qualifier in resource merger.
  • Improved evaluation and IDE sync speeds for projects with a large number of Android modules.

Android Plugin for Gradle, Revision 1.0.1 (January 2015)

Dependencies:
  • Gradle 2.2.1 up to 2.3.x.

    Note: This version of the Android Plugin for Gradle is not compatible with Gradle 2.4 and higher.

  • Build Tools 21.1.1 or higher.
General Notes:
  • Fixed issue with Gradle build failure when accessing the extractReleaseAnnotations module. (Issue 81638).
  • Fixed issue with Disable passing the --no-optimize setting to the Dalvik Executable (dex) bytecode. (Issue 82662).
  • Fixed manifest merger issues when importing libraries with a targetSdkVersion less than 16.
  • Fixed density ordering issue when using Android Studio with JDK 8.

Android Plugin for Gradle, Revision 1.0.0 (December 2014)

Dependencies:
  • Gradle 2.2.1 up to 2.3.x.

    Note: This version of the Android Plugin for Gradle is not compatible with Gradle 2.4 and higher.

  • Build Tools 21.1.1 or higher.
General Notes:
  • Initial plugin release.

Updating the Android Plugin for Gradle Version

The Android Plugin for Gradle version is specified in the File > Project Structure menu or the project-level build.gradle file. The plugin version applies to all modules built in that Android Studio project. This example updates the Android Plugin for Gradle to version 1.1.0:

...
     dependencies {
         classpath 'com.android.tools.build:gradle:1.1.0'
     }
...

Caution: You should not use dynamic dependencies (+) in version numbers. Using this feature can cause unexpected version updates and difficulty resolving version differences.

If you're building with Gradle but using not Android Studio, the build process downloads the latest Android Plugin for Gradle plugin when it runs.

Updating the Gradle Version

Android Studio requires Gradle version 2.2.1 or later. To view and update the Gradle version, edit the Gradle distribution reference in the gradle/wrapper/gradle-wrapper.properties file. This example shows the Android Plugin for Gradle version set to 2.2.1.

...
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
...

For more details about the supported Android Plugin for Gradle properties and syntax, click the link to the Plugin Language Reference.