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 Narwhal 4 Feature Drop | 2025.1.4.
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.
Minimum version | Default version | Notes | |
---|---|---|---|
Gradle | 9.0.0 | 9.0.0 | 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. |
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:
- Switch to 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 thecom.android.library
andcom.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 newandroidComponents
API. This might be more complex, as theandroidComponents
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.
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.
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.
|
false → true |
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.
|
false → true |
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. | false → true |
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.
|
true → false |
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. |
false → true |
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. |
false → true |
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. |
false → true |
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. | false → true |
Remove any invalid proguard files declarations |
android.r8.optimizedResourceShrinking |
Allows R8 to keep fewer Android resources by considering classes and Android resources together. | false → true |
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>(); } |
false → true |
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
|
true → false |
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 | true → false |
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:
- Embedded Wear OS app support
AGP 9.0 removes support for embedding Wear OS apps, which is no longer supported in Play. This includes removing thewearApp
configurations and theAndroidSourceSet.wearAppConfigurationName
DSL. See Distribute to Wear OS for how to publish your app to Wear OS. androidDependencies
andsourceSets
report task
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
toApplicationExtension
,LibraryExension
,DynamicFeatureExtension
andTestExtension
.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:
AndroidComponentsExtension.finalizeDSl
. It is replaced byfinalizeDsl
AndroidSourceSet.jni
, because it was not functional.AndroidSourceSet.wearAppConfigurationName
, as it relates to the removed embedded Wear OS app support.BuildType.isRenderscriptDebuggable
, because it was not functional.Component.transformClassesWith
. It is replaced byInstrumentation.transformClassesWith
Component.setAsmFramesComputationMode
. It is replaced byInstrumentation.setAsmFramesComputationMode
DependenciesInfoBuilder.includedInApk
. Is is replaced byincludeInApk
DependenciesInfoBuilder.includedInBundle
. Is is replaced byincludeInBundle
ComponentBuilder.enabled
. It is replaced byComponentBuilder.enable
.DependencyVariantSelection
. It is replaced ByDependencySelection
, which is exposed askotlin.android
GeneratesApk.targetSdkVersion
. Is is replaced bytargetSdk
Installation.installOptions(String)
. It is replaced by the mutable property ofInstallation.installOptions
.Variant.minSdkVersion
. Is is replaced byminSdk
Variant.maxSdkVersion
. Is is replaced bymaxSdk
Variant.targetSdkVersion
. Is is replaced bytargetSdk
VariantBuilder.targetSdk
andtargetSdkPreview
, as they were not meaningful in libraries. UseGeneratesApkBuilder.targetSdk
orGeneratesApkBuilder.targetSdkPreview
instead.VariantOutput.enable
. Is is replaced byenabled
The experimental, but never stabilized
PostProcessing
block.ProductFlavor.setDimension
, which is replaced by thedimension
propertyLanguageSplitOptions
, which was only useful for Google Play Instant, which is deprecated.Variant.unitTest
, as it was not applicable to thecom.android.test
plugin.unitTest
is available onVariantBuilder
subtypes extendingHasUnitTest
.VariantBuilder.enableUnitTest
, as it was not applicable to thecom.android.test
plugin.enableUnitTest
is available onVariantBuilder
subtypes extendingHasUnitTestBuilder
.VariantBuilder.unitTestEnabled
is removed in favor of the more consistently namedenableUnitTest
on theVariantBuilder
subtypes extendingHasUnitTestBuilder
.
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 } } |
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
andFeatureExtension
.
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. |