Release notes for Android Gradle plugin preview

This page contains release notes for preview releases of the Android Gradle plugin (AGP).

Android Gradle plugin 9.0

Android Gradle plugin 9.0 is a new major release of AGP, and brings API and behavior changes.

To update to Android Gradle plugin 9.0.0-alpha05, use the Android Gradle plugin Upgrade Assistant in Android Studio Otter | 2025.2.1.

The AGP upgrade assistant helps preserve existing behaviors when upgrading your project when appropriate, allowing you to upgrade your project to use AGP 9.0, even if you're not ready to adopt all the new defaults in AGP 9.0.

Compatibility

The maximum Android API level that Android Gradle plugin 9.0.0-alpha05 supports is API level 36.

Android Gradle plugin 9.0.0-alpha05 requires Gradle 9.0.0.

The android DSL classes now only implement the new public interfaces

Over the last several years, we have introduced new interfaces for our DSL and API in order to better control which APIs are public. AGP versions 7.x and 8.x still used the old DSL types (for example BaseExtension) which also implemented the new public interfaces, in order to maintain compatibility as work progressed on the interfaces.

AGP 9.0 uses our new DSL interfaces exclusively, and the implementations have changed to new types that are fully hidden. This changes also removes access to the old, deprecated, variant API.

To update to AGP 9.0, you might need to do the following:

  • Ensure your project is compatible with built-in Kotlin: The org.jetbrains.kotlin.android plugin is not compatible with the new DSL.
  • Switch KMP projects to the Android Gradle Library Plugin for KMP: Using the org.jetbrains.kotlin.multiplatform plugin in the same Gradle subproject as the com.android.library and com.android.application plugins is not compatible with the new DSL.

  • Update your build files: While the change of interfaces is meant to keep the DSL as similar as possible, there might be some small changes.

  • Update your custom build logic to reference the new DSL and API: Replace any references to the internal DSL with the public DSL interfaces. In most cases this will be a one-to-one replacement. Replace any use of the applicationVariants and similar APIs with the new androidComponents API. This might be more complex, as the androidComponents API is designed to be more stable to keep plugins compatible longer. Check our Gradle Recipes for examples.

  • Update third-party plugins: Some third-party plugins might still depend on interfaces or APIs that are no longer exposed. Migrate to versions of those plugins which are compatible with AGP 9.0.

The switch to the new DSL interfaces prevents plugins and Gradle build scripts using various deprecated APIs, including:

Deprecated API in the android block Function Replacement
applicationVariants,
libraryVariants,
testVariants, and
unitTestVariants
Extension points for plugins to add new functionality to AGP. Replace this with the androidComponents.onVariants API, for example:
androidComponents {
    onVariants() { variant ->
        variant.signingConfig
            .enableV1Signing.set(false)
    }
}
There might not be a direct replacement for all previous APIs. File an issue if there is a use case that is not covered by the new variant APIs.
variantFilter Allows selected variants to be disabled. Replace this with the androidComponents.beforeVariants API, for example:
androidComponents {
    beforeVariants(
        selector()
            .withBuildType("debug")
            .withFlavor("color", "blue")
    ) { variantBuilder ->
        variantBuilder.enable = false
    }
  }
deviceProvider and
testServer
Registration of custom test environments for running tests against Android devices and emulators. Switch to Gradle-managed devices.
sdkDirectory,
ndkDirectory,
bootClasspath,
adbExecutable, and
adbExe
Using various components of the Android SDK for custom tasks. Switch to androidComponents.sdkComponents.
registerArtifactType,
registerBuildTypeSourceProvider,
registerProductFlavorSourceProvider,
registerJavaArtifact,
registerMultiFlavorSourceProvider, and
wrapJavaSourceSet
Obsolete functionality mostly related to the handling of generated sources in Android Studio, which stopped working in AGP 7.2.0. There is no direct replacement for these APIs.

If you update to AGP 9.0 and see the following error message, it means that your project is still referencing some of the old types:

java.lang.ClassCastException: class com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated
cannot be cast to class com.android.build.gradle.BaseExtension

If you are blocked by incompatible third-party plugins, you can opt out and get back the old implementations for the DSL, as well as the old variant API. While doing this, the new interfaces are also available, and you can still update your own build logic to the new API. To opt out, include this line in your gradle.properties file:

android.newDsl=false

You can also start upgrading to the new APIs before upgrading to AGP 9.0. The new interfaces have been present for many AGP versions and so you can have a mix of new and old. The AGP API reference docs show the API surface for each AGP version, and when each class, method and field was added.

During the 9.0 alpha phase we're reaching out to plugin authors to help them adapt and release plugins that are fully compatible with the new modes, and will enhance the AGP Upgrade Assistant in Android Studio to guide you through the migration.

If you find that the new DSL or Variant API are missing capabilities or features, please file an issue as soon as possible.

Built-in Kotlin

Android Gradle plugin 9.0 includes built-in support compiling Kotlin, replacing the separately applied Kotlin plugin. This simplifies the integration with AGP, avoiding the use of the deprecated APIs and improving performance in some cases.

Android Gradle plugin 9.0 has a runtime dependency on Kotlin Gradle plugin 2.2.10, which is the minimum version required for built-in kotlin support.

Built-in kotlin in AGP 9.0 brings full Android Studio IDE support for test-fixtures. To try this, use AGP 9.0.0-alpha07 or later.

You can opt out of built-in Kotlin by setting android.builtInKotlin=false.

If you have opted out of built-in Kotlin and also need to use an older version of the Kotlin Gradle plugin, you can force the downgrade:

buildscript {
    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin") {
            version { strictly("2.0.0") } // or another version that you want to use
        }
    }
}

Behavior changes

Android Gradle plugin 9.0 has the following new behaviors:

Behavior Recommendation
Android Gradle plugin 9.0 uses NDK version r28c by default. Consider specifying the NDK version you want to use explicitly.
Android Gradle plugin 9.0 by default requires consumers of a library to use the same or higher compile SDK version. Use the same or higher compile SDK when consuming a library. If this is not possible, or you want to give consumers of a library you publish more time to switch, set AarMetadata.minCompileSdk explicitly.

AGP 9.0 includes updates to the following Gradle properties' defaults. This gives you the choice to preserve the AGP 8.13 behavior when upgrading:

Property Function Change from AGP 8.13 to AGP 9.0 Recommendation
android.newDsl Use the new DSL interfaces, without exposing the legacy implementations of the android block.
This also means the legacy variant API, such as android.applicationVariants is no longer accessible.
falsetrue You can opt out by setting android.newDsl=false.
Once all plugins and build logic your project uses are compatible, remove the opt out.
android.builtInKotlin Enabled support for compiling Kotlin code directly in the Android Gradle plugin, without the org.jetbrains.kotlin.android plugin. falsetrue Adopt built-in Kotlin by removing use of the org.jetbrains.kotlin.android plugin if you can. If not, opt out by setting android.builtInKotlin=false
android.uniquePackageNames Enforces that each library has a distinct package name. falsetrue Specify unique package names for all libraries within your project. If that is not possible, you can disable this flag while you migrate.
android.dependency.useConstraints Controls the use of dependency constraints between configurations.
The default in AGP 9.0 is false which only uses constraints in application device tests (AndroidTest). Setting this to true will revert back to the 8.13 behavior.
truefalse Don't use dependency constraints everywhere unless you need them. Accepting the new default of this flag also enables optimizations in the project import process which should reduce the import time for builds with many android library subprojects.
aandroid.enableAppCompileTimeRClass Compile code in applications against a non-final R class, bringing application compilation in line with library compilation.
This improves incrementality and paves the way for future performance optimizations to the resource processing flow.
falsetrue Many projects can just adopt the new behavior with no source changes. If the R class fields are used anywhere that requires a constant, such as switch cases, refactor to use chained if statements.
android.sdk.defaultTargetSdkToCompileSdkIfUnset Uses the compile SDK version as the default value for the target SDK version in apps and tests.
Before this change, the target SDK version would default to the min SDK version.
falsetrue Specify the target SDK version explicitly for apps and tests.
android.onlyEnableUnitTestForTheTestedBuildType Only creates unit test components for the tested build type.
In the default project this results in a single unit test for debug, where the previous behavor was to have unit tests run for debug or release.
falsetrue If your project doesn't require tests to run for both debug and release, no change is required.
android.proguard.failOnMissingFiles Fails the build with an error if any of the keep files specified in the AGP DSL don't exist on disk. Before this change typos in filenames would result in files being silently ignored. falsetrue Remove any invalid proguard files declarations
android.r8.optimizedResourceShrinking Allows R8 to keep fewer Android resources by considering classes and Android resources together. falsetrue If your project's keep rules are already complete, no change is required.
android.r8.strictFullModeForKeepRules Allows R8 to keep less by not implicitly keeping the default constructor when a class is kept. That is, -keep class A no longer implies -keep class A { <init>(); }
falsetrue If your project's keep rules are already complete, no change is required.

Replace -keep class A with -keep class A { <init>(); } in your project's keep rules for any cases where you need the default constructor to be kept.
android.defaults.buildfeatures.resvalues Enables resValues in all subprojects truefalse Enable resValues in only the subprojects that need it by setting the following in those projects' Gradle build files:
android {
  buildFeatures {
    resValues = true
  }
}
android.defaults.buildfeatures.shaders Enables shader compilation in all subprojects truefalse Enable shader compilation in only the subprojects that contain shaders to be compiled by setting the following in those projects' Gradle build files:
android {
  buildFeatures {
    shaders = true
  }
}

Removed features

Android Gradle plugin 9.0 removes the following functionality:

Changed DSL

Android Gradle plugin 9.0 has the following breaking DSL changes:

  • The parameterization of CommonExtension has been removed.

    In itself, this is only a source-level breaking change to help avoid future source-level breaking changes, but it also means that the block methods need to move from CommonExtension to ApplicationExtension, LibraryExension, DynamicFeatureExtension and TestExtension.

    When upgrading your project to AGP 9.0, refactor Gradle plugin code which uses those parameters or the block methods. For example the following plugin is updated to remove the type parameter and not rely on the removed block methods:

    AGP 8.13

    val commonExtension: CommonExtension<*, *, *, *, *, *> =
            extensions.getByType(CommonExtension::class)
    commonExtension.apply {
        defaultConfig {
            minSdk {
                version = release(28)
            }
        }
    }
    

    AGP 9.0

    val commonExtension: CommonExtension =
            extensions.getByType(CommonExtension::class)
    commonExtension.apply {
        defaultConfig.apply {
            minSdk {
                version = release(28)
            }
        }
    }
    

    For plugins which target a range of AGP versions, using the getter directly is binary compatible with AGP versions lower than 9.0.

Removed DSL

Android Gradle plugin 9.0 removes:

Removed Gradle properties

The following Gradle properties were initially added as ways to globally disable features that were enabled by default.

These features have been disabled by default since AGP 8.0 or lower. Enable these features in only the sub-projects that use them for a more efficient build.

Property Function Replacement
android.defaults.buildfeatures.aidl Enables AIDL compilation in all subprojects Enable AIDL compilation in only the subprojects where there are AIDL sources by setting the following property in those projects' Gradle build files:
android {
  buildFeatures {
    aidl = true
  }
}
in the Gradle build file of each subproject containing AIDL sources
android.defaults.buildfeatures.renderscript Enables RenderScript compilation in all subprojects Enable renderscript compilation in only the subprojects where there are renderscript sources by setting the following property in those projects' Gradle build files:
android {
  buildFeatures {
    renderScript = true
  }
}

Removed APIs

Android Gradle plugin 9.0 removes:

  • The deprecated and disabled BaseExtension.registerTransform APIs, which only remained to allow compiling against the latest AGP version while targeting running on AGP 4.2 or lower.

  • The deprecated and disabled FeaturePlugin and FeatureExtension.

Enforced Gradle properties

AGP 9.0 throws an error if you set the following Gradle properties.

The Android Gradle plugin Upgrade Assistant won't upgrade projects to AGP 9.0 that use these properties.

Property Function
android.r8.integratedResourceShrinking Resource shrinking is now always run as part of R8, the previous implementation has been removed.

Fixed issues

Android Gradle plugin 9.0.0-alpha08

Fixed Issues
No public issues were marked as fixed in AGP 9.0.0-alpha08

Android Gradle plugin 9.0.0-alpha07

Fixed Issues
Android Gradle Plugin
A build fails if there are code generation tasks
With `android.builtInKotlin=false` and `android.newDsl=false` and `android.enableLegacyVariantApi=false`, using `kotlin-android` plugin will fail with "API 'applicationVariants' is obsolete"
Built-in Kotlin fails to resolve unversioned kotlin-stdlib when kotlin.stdlib.default.dependency=false
DexData opens a file without closing, preventing cleanup
AndroidSourceDirectorySet should stop extending PatternFilterable in AGP 9.0
Test Fixture Error in test only modules
Incorrect error when using context receivers in test fixtures
Incorrect IDE errors for Kotlin code in testFixtures

Android Gradle plugin 9.0.0-alpha06

Fixed Issues
Android Gradle Plugin
New optimizaation DSL does not create configuration.txt by default
AGP 8.13.0 fails to verify nav graph in a module
AGP uses deprecated Gradle API: multi-string notation
Warn users trying to use legacy multidex library with minSdkVersion >=21
Lint
Lint ChecksSdkIntAtLeast Check does not check if the annotated value is correct

Android Gradle plugin 9.0.0-alpha05

Fixed Issues
Android Gradle Plugin
android.proguard.failOnMissingFiles is not working for consumerProguardFiles
Update Kotlin Gradle plugin dependency to 2.2.10
Create KotlinJvmAndroidCompilation using KGP API
Kotlin explicit API mode applied to test sources
Lint
Lint throwing warning "Could not clean up K2 caches"

Android Gradle plugin 9.0.0-alpha04

Fixed Issues
Android Gradle Plugin
Switch default source/target Java version from Java 8 to Java 11 in AGP 9.0
Flip android.useAndroidX default to true
Better exception when applying kapt plugin with built-in Kotlin.
Lint
Lint throwing warning "Could not clean up K2 caches"

Android Gradle plugin 9.0.0-alpha03

Fixed Issues
Android Gradle Plugin
When `isIncludeAndroidResources` is enabled, `process{Variant}UnitTestManifest` fails to merge tools:overrideLibrary usages in AGP 8.12.0
AGP causing deprecation warnings in Gradle for JVM test tasks
DependencyReportTask is incompatible with the configuration cache
Lint
Bug: removal of unused resources doesn't also remove the translations of them, and doesn't ask about it either

Android Gradle plugin 9.0.0-alpha02

Fixed Issues
Android Gradle Plugin
Fail build when proguard file does not exist
remove buildconfig defaults gradle.properties flags
Change the app’s targetSdk default value to be based on compileSdk instead of minSdk

Android Gradle plugin 9.0.0-alpha01

Fixed Issues
Android Gradle Plugin
Remove deprecated AndroidSourceSet.jni in AGP 9.0
Remove Installation.installOptions() in AGP 9.0
Remove BuildType.isRenderscriptDebuggable in AGP 9.0.
Remove android.defaults.buildfeatures.renderscript
`com.android.kotlin.multiplatform.library` crashes with Gradle Managed Devices
Remove `android.defaults.buildfeatures.aidl` defaults gradle.properties flags