使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android Gradle 插件 2.1.0(2016 年 4 月)
2.1.3(2016 年 8 月)
此更新需要使用 Gradle 2.14.1 及更高版本。Gradle 2.14.1 加入了一些性能改进、新功能和一个重要的安全修复程序。如需了解详情,请参阅 Gradle 版本说明。
- 依赖项:
|
最低版本 |
默认版本 |
备注 |
Gradle |
2.10 |
2.10 |
如需了解详情,请参阅更新 Gradle。 |
SDK Build Tools |
23.0.2 |
23.0.2 |
安装或配置 SDK Build Tools。 |
- 新功能:
-
- 添加了对 N 开发者预览版、JDK 8 以及使用 Jack 工具链的 Java 8 语言功能的支持。如需了解详情,请阅读 N 预览版指南。
注意:Instant Run 目前无法用于 Jack,在使用新的工具链时将被停用。如果您正在为 N 预览版开发应用,并希望使用受支持的 Java 8 语言功能,只需使用 Jack 即可。
- 添加了对增量 Java 编译的默认支持,以在开发过程中缩短编译时间。这种编译方式仅对已发生变化或需要重新编译的那部分源代码进行重新编译。如需停用此功能,请将以下代码添加到模块级
build.gradle
文件中:
Groovy
android {
...
compileOptions {
incremental false
}
}
Kotlin
android {
...
compileOptions {
incremental = false
}
}
-
添加了对 dexing-in-process 的支持。dexing-in-process 会在构建流程(而不是单独的外部虚拟机流程)中执行 dex 处理。这样不仅可以让增量构建更快,还可以加快完整构建的速度。对于已将 Gradle 守护程序的最大堆大小设置为不小于 2048 MB 的项目,该功能默认处于启用状态。如需进行设置,您可以将以下代码添加到项目的 gradle.properties
文件中:
```none
org.gradle.jvmargs = -Xmx2048m
```
如果您已经在模块级 build.gradle
文件中为 javaMaxHeapSize
定义值,则需要将 org.gradle.jvmargs
的值设置为“javaMaxHeapSize
+ 1024MB”的结果。例如,如果您将 javaMaxHeapSize
设置为“2048m”,则需要将以下代码添加到项目的 gradle.properties
文件中:
```none
org.gradle.jvmargs = -Xmx3072m
```
如需停用 dexing-in-process,请将以下代码添加到模块级 build.gradle
文件中:
Groovy
android {
...
dexOptions {
dexInProcess false
}
}
Kotlin
android {
...
dexOptions {
dexInProcess = false
}
}
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-27。
[null,null,["最后更新时间 (UTC):2025-08-27。"],[],[],null,["\u003cbr /\u003e\n\nAndroid Gradle Plugin 2.1.0 (April 2016)\n\n\u003cbr /\u003e\n\n\n**2.1.3 (August 2016)**\n\nThis update requires Gradle 2.14.1 and higher. Gradle 2.14.1 includes\nperformance improvements, new features, and an important [security fix](https://docs.gradle.org/2.14/release-notes#local-privilege-escalation-when-using-the-daemon). For more details, see the\n[Gradle release notes](https://docs.gradle.org/2.14.1/release-notes).\n\nDependencies:\nNew:\n:\n - Added support for the N Developer Preview, JDK 8, and [Java 8 language features](/preview/j8-jack) using the Jack toolchain. To find out more, read the [N Preview guide](/about/versions/nougat).\n\n\n **Note:** [Instant\n Run](/tools/building/building-studio#instant-run) does not currently work with Jack and will be disabled while\n using the new toolchain. You only need to use Jack if you are developing\n for the N Preview and want to use the supported Java 8 language features.\n - Added default support for incremental Java compilation to reduce compilation time during development. It does this by only recompiling portions of the source that have changed or need to be recompiled. To disable this feature, add the following code to your module-level `build.gradle` file: \n\n Groovy \n\n ```groovy\n android {\n ...\n compileOptions {\n incremental false\n }\n }\n ```\n\n Kotlin \n\n ```kotlin\n android {\n ...\n compileOptions {\n incremental = false\n }\n }\n ```\n -\n Added support for dexing-in-process which performs dexing within the build\n process rather than in a separate, external VM processes. This not only makes\n incremental builds faster, but also speeds up full builds. The feature is\n enabled by default for projects that have set the Gradle daemon's maximum heap\n size to at least 2048 MB. You can do this by including the following in your\n project's `gradle.properties` file:\n\n \\`\\`\\`none org.gradle.jvmargs = -Xmx2048m \\`\\`\\`\n\n\n If you have defined a value for [`javaMaxHeapSize`](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.DexOptions.html#com.android.build.gradle.internal.dsl.DexOptions:javaMaxHeapSize) in your module-level `build.gradle`\n file, you need to set `org.gradle.jvmargs` to the value of\n `javaMaxHeapSize` + 1024 MB. For example, if you have set\n `javaMaxHeapSize` to \"2048m\", you need to add the following to your\n project's `gradle.properties` file:\n \\`\\`\\`none org.gradle.jvmargs = -Xmx3072m \\`\\`\\`\n\n\n To disable dexing-in-process, add the following code to your module-level `build.gradle` file: \n\n Groovy \n\n ```groovy\n android {\n ...\n dexOptions {\n dexInProcess false\n }\n }\n ```\n\n Kotlin \n\n ```kotlin\n android {\n ...\n dexOptions {\n dexInProcess = false\n }\n }\n ```"]]