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-alpha04, 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-alpha04 supports is API level 36.
Android Gradle plugin 9.0.0-alpha04 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. |
Internal DSL implementations and deprecated variant API now require explicit opt in
The Android Gradle plugin now has a defined API surface, with supported APIs
defined in the com.android.tools.build:gradle-api
maven artifact.
For compatibility with existing binary plugins and build scripts, the previous
DSL implementations that predate that defined API surface were still exposed By
default in AGP 8.13 and lower. This allows code in Gradle
plugins and build scripts to access to both internal implementation details of
the DSL as well as the deprecated android.applicationVariants
,
android.libraryVariants
,
android.testVariants
and android.unitTestVariants
APIs, which
will be removed in 2026 in AGP 10.
To make this transition more visible, both the legacy variant API and the internal DSL are not accessible by default Android Gradle plugin 9.0.0-alpha04.
You can opt-back in to use the deprecated API by setting
android.newDsl=false
in gradle.properties
.
During the 9.0 alpha series 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.
Built-in Kotlin
Android Gradle plugin 9 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 has a runtime dependency on Kotlin Gradle plugin 2.2.0, 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 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.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 DSL block methods need to move fromCommonExtension
toApplicationExtension
,LibraryExension
,DynamicFeatureExtension
andTestExtension
.
Removed DSL
Android Gradle plugin 9.0 removes:
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.ComponentBuilder.enabled
. It is replaced byComponentBuilder.enable
.DependencyVariantSelection
. It is replaced ByDependencySelection
, which is exposed askotlin.android
Installation.installOptions(String)
. It is replaced by the mutable property ofInstallation.installOptions
.VariantBuilder.targetSdk
andtargetSdkPreview
, as they were not meaningful in libraries. UseGeneratesApkBuilder.targetSdk
orGeneratesApkBuilder.targetSdkPreview
instead.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.
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. |