Android Gradle 插件 7.4.0(2023 年 1 月)
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android Gradle 插件 7.4.0 是一个主要版本,包含各种新功能和改进。
兼容性
|
最低版本 |
默认版本 |
备注 |
Gradle |
7.5 |
7.5 |
如需了解详情,请参阅更新 Gradle。 |
SDK Build Tools |
30.0.3 |
30.0.3 |
安装或配置 SDK Build Tools。 |
NDK |
不适用 |
23.1.7779620 |
安装或配置其他版本的 NDK。 |
JDK |
11 |
11 |
如需了解详情,请参阅设置 JDK 版本。 |
AGP 升级助理升级后报告和回滚功能
AGP 升级助理现在包含升级后报告。此报告介绍了已完成的步骤以及升级是成功还是失败。它还包含一项操作,如果在升级后构建或测试项目时遇到问题,用来还原由升级助理所做的更改。
项目导入作业并行运行
现在,当您使用 Gradle 7.4.2 或更高版本以及 Android Gradle 插件 7.2.0 或更高版本时,Studio IDE 会并行导入项目。具体而言,当 Android Studio 触发 Gradle 同步时,系统将并行创建用于描述 build 中所含项目的信息。这通常能加快同步过程,对于较大的项目,尤为如此。基准测试表明,为一个大型项目(包含 3,500 个 Gradle 子项目)构建 Gradle 模型所需的时间缩短了 50%,从 10 分钟缩短为 5 分钟。
Android Gradle 插件适用于 JVM 11 字节码
从 Android Gradle 插件 7.4.0-alpha04 开始,AGP 附带 JVM 11 字节码。这意味着,如果您针对 AGP 进行编译或编写自定义 lint 检查,则需要开始以 JVM 11 字节码为目标适用对象。其中一种方法是在模块级 build.gradle
文件中添加以下代码:
sourceCompatibility = "11"
targetCompatibility = "11"
补丁版本
以下是 Android Gradle 插件 7.4 的补丁版本列表。
Android Gradle 插件 7.4.1(2023 年 2 月)
本次要更新包含以下 bug 修复:
修复的问题 |
从 destination 属性迁移到 outputLocation 属性,以解决废弃警告问题并为 Gradle 9.0 做好准备
|
AGP 7.4.0-rc01 会破坏 Variant API,并显示“Querying the mapped value of
map(provider(java.util.Set)) before task '...' has completed is not supported”
|
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-27。
[null,null,["最后更新时间 (UTC):2025-08-27。"],[],[],null,["Android Gradle Plugin 7.4.0 is a major release that includes a variety of new\nfeatures and improvements.\n\nCompatibility\n\n\n| | Minimum version | Default version | Notes |\n|----------------:|:---------------:|:---------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------:|\n| Gradle | 7.5 | 7.5 | To learn more, see [updating Gradle](/build/releases/gradle-plugin?buildsystem=ndk-build#updating-gradle). |\n| SDK Build Tools | 30.0.3 | 30.0.3 | [Install](/studio/intro/update#sdk-manager) or [configure](/tools/releases/build-tools) SDK Build Tools. |\n| NDK | N/A | 23.1.7779620 | [Install](/studio/projects/install-ndk#specific-version) or [configure](/studio/projects/install-ndk#apply-specific-version) a different version of the NDK. |\n| JDK | 11 | 11 | To learn more, see [setting the JDK version](/studio/intro/studio-config#jdk). |\n\n\u003cbr /\u003e\n\nAGP Upgrade Assistant post-upgrade report and rollback functionality\n\nThe AGP Upgrade Assistant now includes a post-upgrade report. This report\ndescribes the steps that were completed and if the upgrade was successful or\nunsuccessful. It also includes an action to revert changes that were made by\nthe upgrade assistant, if there are issues building or testing the project\nafter the upgrade.\n\nProject import runs in parallel\n\nThe Studio IDE now imports projects in parallel when you use Gradle 7.4.2 or\nhigher and Android Gradle plugin 7.2.0 or higher. Specifically, when Android\nStudio triggers a Gradle sync, the information that describes projects included\nin your build is created in parallel. This usually speeds up the syncing\nprocess, especially for larger projects. Benchmarks show that the time it takes\nto build Gradle models for a very large project (with 3,500 Gradle subprojects)\nis reduced by 50%, from 10 minutes to 5 minutes.\n\nAndroid Gradle plugin targets JVM 11 bytecode\n\nStarting with Android Gradle plugin 7.4.0-alpha04, AGP ships wth JVM 11\nbytecode. This means that if you compile against AGP, or write custom Lint\nchecks, you need to start targeting JVM 11 bytecode. One of the ways to do this\nis to include the following in your module-level `build.gradle` file: \n\n sourceCompatibility = \"11\"\n targetCompatibility = \"11\"\n\nPatch releases\n\n\u003cbr /\u003e\n\nThe following is a list of the patch releases for Android Gradle Plugin\n7.4.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nAndroid Gradle Plugin 7.4.1 (February 2023)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis minor update includes the following bug fixes:\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Fixed issues ||\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [Issue #242831042](https://issuetracker.google.com/issues/242831042) Migrate from `destination` property to `outputLocation` property to address deprecation warning and prepare for Gradle 9.0 |\n| [Issue #261329823](https://issuetracker.google.com/issues/261329823) AGP 7.4.0-rc01 breaks Variant API with \"Querying the mapped value of `map(provider(java.util.Set))` before task '...' has completed is not supported\" |\n\n\u003cbr /\u003e"]]