Android Gradle plugin 9.6.0

Android Gradle plugin 9.6 is a minor release that includes a variety of new features and improvements.

Compatibility

The maximum API level that Android Gradle plugin 9.6 supports is API level 37. Here is other compatibility info:

Minimum version Default version Notes
Gradle 9.8.2 9.8.2 To learn more, see updating Gradle.
SDK Build Tools 36.0.0 36.0.0 Install or configure SDK Build Tools.
NDK N/A 28.2.13676358 Install or configure a different version of the NDK.
JDK 17 17 To learn more, see setting the JDK version.

Unified coverage and test reports

AGP 9.6.0-alpha05 introduces tasks to generate HTML dashboards that consolidate test results and coverage from various test types (unit and instrumentation), modules, and build variants, providing a comprehensive overview in a single dashboard. For more information, see Generate unified code coverage reports and View unified test reports.

On-device code coverage for instrumented tests

AGP 9.6.0-alpha01 adds on-device code coverage for instrumented tests. Instead of instrumenting your app's classes with JaCoCo at build time, AGP adds a coverage agent to your test APK, and the agent instruments the classes on the test device while your tests run. This removes the JaCoCo instrumentation step from builds that have enableAndroidTestCoverage enabled, and keeps coverage-tracking code out of your app's APK. You run the same create{Variant}AndroidTestCoverageReport task, and AGP generates the HTML and XML reports in the same location. On-device code coverage requires a debuggable app and a device that runs Android 9 (API level 28) or higher.

AGP adds the coverage agent library, com.android.tools.test:coverage-agent, with the same version as AGP. For more information, see View code coverage reports (with on-device agent).

Test suites

AGP 9.6 adds the following updates for the testOptions.customSuites block:

  • Access merged Android resources and run Robolectric tests on the JVM by setting the enableAndroidResources property in the hostJar block.
  • Run testApk suites in com.android.library modules, target build-managed device groups in the targetDevices property, filter tests with the --tests option, and use automatic manifest runner configuration.
  • Customize Gradle Test tasks per target with the AgpTestSuiteTarget.configureTestTasks method.
  • Collect code coverage with the codeCoverage property for Compose screenshot suites through the testOptions.customSuites block and for instrumented and mixed suites with the on-device coverage agent.
  • Match the com.android.tools.androidtest:android-test-engine and android-test-engine-result-listener dependency versions directly to the AGP version.

For more information, see Test suites in the Android Gradle plugin, Unit test suites, and Instrumented test suites.

Fixed issues

Android Gradle plugin 9.6.0-alpha03

Fixed Issues
Android Gradle Plugin
Ladybug UI is slower than Koala
Make analyzeReleaseR8Config output print out link to the report
IDE Performance Slows to a Crawl During Gradle Build in large project
Lint Integration
[AGP 9.x] Broken Gradle cache: Moving sources fails Lint analysis

Android Gradle plugin 9.6.0-alpha02

Fixed Issues
Android Gradle Plugin
Unsafe system properties read for R8 tasks

Android Gradle plugin 9.6.0-alpha01

Fixed Issues
Android Gradle Plugin
shrinkresources does not work with library apks due to recent aapt2 change
Lint
Lint ThreadConstraint partial results are not deterministic across JVMs, which breaks build cache for lintAnalyze