Android Gradle Plugin 3.3.0 (January 2019)

This version of the Android plugin requires the following:

Minimum version Default version Notes
Gradle 4.10.1 4.10.1 To learn more, see updating Gradle. When using Gradle 5.0 and higher, the default Gradle daemon memory heap size decreases from 1 GB to 512 MB. This might result in a build performance regression. To override this default setting, specify the Gradle daemon heap size in your project's gradle.properties file.
SDK Build Tools 28.0.3 28.0.3 Install or configure SDK Build Tools.

3.3.3 (July 2020)

This minor update supports compatibility with new default settings and features for package visibility in Android 11.

See the 4.0.1 release notes for details.

3.3.2 (March 2019)

This minor update supports Android Studio 3.3.2 and includes various bug fixes and performance improvements. To see a list of noteable bug fixes, read the related post on the Release Updates blog.

3.3.1 (February 2019)

This minor update supports Android Studio 3.3.1 and includes various bug fixes and performance improvements.

New features

  • Improved classpath synchronization: When resolving dependencies on your runtime and compile time classpaths, the Android Gradle plugin attempts to fix certain downstream version conflicts for dependencies that appear across multiple classpaths.

    For example, if the runtime classpath includes Library A version 2.0 and the compile classpath includes Library A version 1.0, the plugin automatically updates the dependency on the compile classpath to Library A version 2.0 to avoid errors.

    However, if the runtime classpath includes Library A version 1.0 and the compile includes Library A version 2.0, the plugin does not downgrade the dependency on the compile classpath to Library A version 1.0, and you will get an error. To learn more, see Fix conflicts between classpaths.

  • Improved incremental Java compilation when using annotation processors: This update decreases build time by improving support for incremental Java compilation when using annotation processors.

    Note: This feature is compatible with Gradle 4.10.1 and higher, except Gradle 5.1 due to Gradle issue 8194.

    • For projects using Kapt (most Kotlin-only projects and Kotlin-Java hybrid projects): Incremental Java compilation is enabled, even when you use data binding or the retro-lambda plugin. Annotation processing by the Kapt task is not yet incremental.

    • For projects not using Kapt (Java-only projects): If the annotation processors you use all support incremental annotation processing, incremental Java compilation is enabled by default. To monitor incremental annotation processor adoption, watch Gradle issue 5277.

      If, however, one or more annotation processors do not support incremental builds, incremental Java compilation is not enabled. Instead, you can include the following flag in your gradle.properties file:

      android.enableSeparateAnnotationProcessing=true
                  

      When you include this flag, the Android Gradle plugin executes the annotation processors in a separate task and allows the Java compilation task to run incrementally.

  • Better debug info when using obsolete API: When the plugin detects that you're using an API that's no longer supported, it can now provide more-detailed information to help you determine where that API is being used. To see the additional info, you need to include the following in your project's gradle.properties file:

              android.debug.obsoleteApi=true
            

    You can also enable the flag by passing -Pandroid.debug.obsoleteApi=true from the command line.

  • You can run instrumentation tests on feature modules from the command line.

Behavior changes

  • Lazy task configuration: The plugin now uses Gradle’s new task creation API to avoid initializing and configuring tasks that are not required to complete the current build (or tasks not on the execution task graph). For example, if you have multiple build variants, such as “release” and “debug” build variants, and you're building the “debug” version of your app, the plugin avoids initializing and configuring tasks for the “release” version of your app.

    Calling certain older methods in the Variants API, such as variant.getJavaCompile(), might still force task configuration. To make sure that your build is optimized for lazy task configuration, invoke new methods that instead return a TaskProvider object, such as variant.getJavaCompileProvider().

    If you execute custom build tasks, learn how to adapt to Gradle’s new task-creation API.

  • For a given build type, when setting useProguard false, the plugin now uses R8 instead of ProGuard to shrink and obfuscate your app’s code and resources. To learn more about R8, read this blog post from the Android Developer’s Blog.

  • Faster R class generation for library projects: Previously, the Android Gradle plugin would generate an R.java file for each of your project's dependencies and then compile those R classes alongside your app's other classes. The plugin now generates a JAR containing your app's compiled R class directly, without first building intermediate R.java classes. This optimization may significantly improve build performance for projects that include many library subprojects and dependencies, and improve the indexing speed in Android Studio.

  • When building an Android App Bundle, APKs generated from that app bundle that target Android 6.0 (API level 23) or higher now include uncompressed versions of your native libraries by default. This optimization avoids the need for the device to make a copy of the library and thus reduces the on-disk size of your app. If you'd rather disable this optimization, add the following to your gradle.properties file:

    android.bundle.enableUncompressedNativeLibs = false
            
  • The plugin enforces minimum versions of some third-party plugins.

  • Single-variant project sync: Syncing your project with your build configuration is an important step in letting Android Studio understand how your project is structured. However, this process can be time-consuming for large projects. If your project uses multiple build variants, you can now optimize project syncs by limiting them to only the variant you have currently selected.

    You need to use Android Studio 3.3 or higher with Android Gradle Plugin 3.3.0 or higher to enable this optimization. When you meet these requirements, the IDE prompts you to enable this optimization when you sync your project. The optimization is also enabled by default on new projects.

    To enable this optimization manually, click File > Settings > Experimental > Gradle (Android Studio > Preferences > Experimental > Gradle on a Mac) and select the Only sync the active variant checkbox.

    Note: This optimization fully supports projects that include Java and C++ languages, and has some support for Kotlin. When enabling the optimization for projects with Kotlin content, Gradle sync falls back to using full variants internally.

  • Automatic downloading of missing SDK packages: This functionality has been expanded to support NDK. To learn more, read Auto-download missing packages with Gradle.

Bug Fixes

  • Android Gradle plugin 3.3.0 fixes the following issues:

    • The build process calling android.support.v8.renderscript.RenderScript instead of the AndroidX version, despite Jetifier being enabled
    • Clashes due to androidx-rs.jar including statically bundled annotation.AnyRes
    • When using RenderScript, you no longer have to manually set the Build Tools version in your build.gradle files