Android Gradle plugin 8.0.0 is a major release that includes a variety of new features and improvements.
Compatibility
Minimum version | Default version | Notes | |
---|---|---|---|
Gradle | 8.0 | 8.0 | To learn more, see updating Gradle. |
SDK Build Tools | 30.0.3 | 30.0.3 | Install or configure SDK Build Tools. |
NDK | N/A | 25.1.8937393 | Install or configure a different version of the NDK. |
JDK | 17 | 17 | To learn more, see setting the JDK version. |
Patch releases
The following is a list of the patch releases for Android Gradle Plugin 8.0.
Android Gradle Plugin 8.0.2 (May 2023)
For a list of bugs fixed in AGP 8.0.2, see the Android Studio 2022.2.1 closed issues.
Android Gradle Plugin 8.0.1 (May 2023)
This minor update includes the following bug fixes:
Fixed issues | |
---|---|
Error: "No VersionRequirement with the given id in the table" after upgrading AGP 7.2.2 -> 7.4.0
|
|
R8 NullPointerException at markTypeAsLive AGP 7.4.1
|
|
[R8 4.0.53] Hard class verification failure on Android 11
|
Breaking change: namespace required in module-level build script
You must set the namespace in the module-level build.gradle.kts
file, rather
than the manifest file. You can start using the namespace
DSL property
starting with AGP 7.3. To learn more, see
Set a namespace.
When migrating to the namespace DSL, be aware of the following issues:
- Previous versions of AGP infer the test namespace from the main namespace, or
application ID, incorrectly in some cases. The AGP Upgrade Assistant blocks the
upgrade if it finds that your project's main namespace and test namespace are
the same. If the upgrade is blocked, you need to manually change
testNamespace
and modify your source code accordingly. - After you change the test namespace, it's possible that your code compiles
but your instrumented tests fail at runtime. This can happen if your
instrumented test source code references a resource defined in both your
androidTest
and app sources.
For more information, see issue #191813691 comment #19.
Breaking changes: build option default values
Starting with AGP 8.0, the default values for these flags have changed to improve build performance. To get help adjusting your code to support some of these changes, use the AGP Upgrade Assistant (Tools > AGP Upgrade Assistant). The Upgrade Assistant guides you through updating your code to accommodate the new behavior or setting flags to preserve the previous behavior.
Flag | New default value | Previous default value | Notes |
---|---|---|---|
android.defaults.buildfeatures.buildconfig |
false |
true |
AGP 8.0 doesn't generate BuildConfig by default. You need
to specify this option using the DSL in the projects where you need it. |
android.defaults.buildfeatures.aidl |
false |
true |
AGP 8.0 doesn't enable AIDL support by default. You need to specify this option using the DSL in the projects where you need it. This flag is planned to be removed in AGP 9.0. |
android.defaults.buildfeatures.renderscript |
false |
true |
AGP 8.0 doesn't enable RenderScript support by default. You need to specify this option using the DSL in the projects where you need it. This flag is planned to be removed in AGP 9.0. |
android.nonFinalResIds |
true |
false |
AGP 8.0 generates R classes with non-final fields by
default. |
android.nonTransitiveRClass |
true |
false |
AGP 8.0 generates R classes for resources defined in
the current module only. |
android.enableR8.fullMode |
true |
false |
AGP 8.0 enables R8 full mode by default. For more details, see R8 full mode. |
Breaking changes: enforced build option values
Starting with AGP 8.0, you can no longer change the values for these flags. If
you specify them in the gradle.properties
file, the value is ignored and AGP
prints warnings.
Flag | Enforced value | Notes |
---|---|---|
android.dependencyResolutionAtConfigurationTime.warn |
true |
AGP 8.0 emits a warning if it detects configuration resolution during the configuration phase because it negatively impacts Gradle configuration times. |
android.r8.failOnMissingClasses |
true |
AGP 8.0 fails builds that use R8 if there are missing classes to
ensure better DEX optimization. To address this, you need to add the
missing libraries or -dontwarn keep rules. For more details,
see
Missing class warnings in R8 shrinker. |
android.testConfig.useRelativePath |
true |
When support for using Android resources, assets, and manifests in
unit tests is enabled, AGP 8.0 generates a
test_config.properties file that contains only relative
paths. This ensures that Android unit tests can always use the Gradle
build cache. |
android.useNewJarCreator |
true |
AGP uses the Zipflinger library when creating JAR files to improve build performance. |
android.bundletool.includeRepositoriesInDependencyReport |
true |
When adding SDK dependency information in AABs and APKs is enabled, AGP 8.0 also adds a list of project repositories to this information. To learn more, see Dependency information for Play Console. |
android.enableArtProfiles |
true |
Baseline profiles are now always generated. See Baseline Profiles for details. |
android.enableNewResourceShrinker |
true |
Use the new resource shinker implementation by default. The new resource shrinker includes support for dynamic features. |
android.enableSourceSetPathsMap |
true |
Used for computing relative resource path mappings, so Gradle builds are up-to-date more often. |
android.cacheCompileLibResources |
true |
Compiled library resources can now be cached by default because Gradle
tracks resources files relative to the project location. Requires
android.enableSourceSetPathsMap to be enabled. |
android.disableAutomaticComponentCreation |
true |
AGP 8.0 creates no SoftwareComponent by default. Instead AGP creates SoftwareComponents only for variants that are configured to be published using the publishing DSL. |
New stable flag for execution profile
AGP includes the new flag android.settings.executionProfile
. Use this flag to
override the default execution profile from the
SettingsExtension
.
To learn more, see the settings plugin documentation.
To preview experimental flags, see the preview release notes.
Kotlin lazy property assignment not supported
If you're using Gradle's Kotlin DSL for your build scripts, note that Android
Studio and AGP 8.0 don't support the experimental property assignment using the
=
operator. For more information about this feature, see the
release notes
and
documentation.
Build Analyzer task categories
Starting with Android Studio Flamingo, Build Analyzer has a new default view for tasks that impact build duration. If your project uses AGP 8.0 or higher, instead of displaying tasks individually, Build Analyzer groups them by category. For example, tasks specific to Android Resources, Kotlin, or Dexing are grouped together and then sorted by build duration. This makes it easy to know what category has the most impact on build time. Expanding each category displays a list of the corresponding tasks. To display tasks individually, without grouping, use the Group by drop-down.
New settings plugin
AGP 8.0.0-alpha09 introduces the new settings plugin. The settings plugin lets you centralize global configurations—configurations that apply to all modules—in one place so you don't need to copy and paste the configurations in multiple modules. In addition, you can use the settings plugin to create tool execution profiles, or different instructions for how to run a tool, and switch among them.
To use the settings plugin, apply the plugin in the settings.gradle
file:
apply plugin 'com.android.settings'
Centralize global configurations
To configure global configurations, use the new android
block in the
settings.gradle
file. Here's an example:
android {
compileSdk 31
minSdk 28
...
}
Tool execution profiles
The settings plugin also lets you create execution profiles for some tools. An execution profile determines how a tool is run; you can select different execution profiles depending on the environment. In an execution profile, you can set JVM arguments for a tool and configure it to run in a separate process. Currently, only the R8 tool is supported.
Create execution profiles and set the default execution profile in the
settings.gradle
file, as shown in the following example:
android {
execution {
profiles {
high {
r8 {
jvmOptions += ["-Xms2048m", "-Xmx8192m", "-XX:+HeapDumpOnOutOfMemoryError"]
runInSeparateProcess true
}
}
low {
r8 {
jvmOptions += ["-Xms256m", "-Xmx2048m", "-XX:+HeapDumpOnOutOfMemoryError"]
runInSeparateProcess true
}
}
ci {
r8.runInSeparateProcess false
}
}
defaultProfile "low"
}
}
To override the default profile, select a different profile using the
android.experimental.settings.executionProfile
property in the
gradle.properties
file:
android.experimental.settings.executionProfile=high
You can also set this property using the command line, which lets you set up
different workflows. For example if you have a continuous integration workflow
you can use the command line to change the execution profile without having to
change the settings.gradle
file:
./gradlew assembleRelease \
-Pandroid.experimental.settings.executionProfile=ci
JDK 17 required to run AGP 8.0
When using Android Gradle Plugin 8.0 to build your app, JDK 17 is now required to run Gradle. Android Studio Flamingo bundles JDK 17 and configures Gradle to use it by default, which means that most Android Studio users don't need to make any configuration changes to their projects.
If you need to manually set the JDK version used by AGP inside of Android Studio, you need to use JDK 17 or higher.
When using AGP independent of Android Studio, upgrade the JDK version by
setting the JAVA_HOME
environment variable
or the -Dorg.gradle.java.home
command-line option
to your installation directory of JDK 17.
Fixed issues
Android Gradle plugin 8.0.0
Fixed Issues | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Android Gradle Plugin |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Dexer (D8) |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Lint |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Lint Integration |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Shrinker (R8) |
|
Android Gradle plugin 8.0.1
Fixed Issues | ||||
---|---|---|---|---|
Shrinker (R8) |
|
Android Gradle plugin 8.0.2
Fixed Issues | |||||
---|---|---|---|---|---|
Shrinker (R8) |
|