使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android Gradle 插件 2.0.0(2016 年 4 月)
- 依赖项:
|
最低版本 |
默认版本 |
备注 |
Gradle |
2.10 |
2.10 |
如需了解详情,请参阅更新 Gradle。 |
SDK Build Tools |
21.1.1 |
21.1.1 |
安装或配置 SDK Build Tools。 |
- 新功能:
-
- 通过支持字节码注入,然后将代码和资源更新推送到模拟器或实体设备上正在运行的应用,来启用 Instant Run。
- 添加了对增量构建的支持,即使应用未运行也支持。
通过 Android 调试桥将增量更改推送到已连接的设备,缩短了整体构建时间。
- 添加了
maxProcessCount
,以控制可以同时衍生多少个工作器 dex 处理进程。以下代码在模块级 build.gradle
文件中将最大并发进程数设置为 4:
android {
...
dexOptions {
maxProcessCount = 4 // this is the default value
}
}
android {
...
dexOptions {
maxProcessCount = 4 // this is the default value
}
}
- 添加了实验性代码缩减器,以支持 dex 预处理和减少对依赖项的重复 dex 处理,而这些不受 Proguard 支持。这提高了调试 build 变体的构建速度。由于实验性缩减器不支持优化和混淆处理功能,因此您应该为发布 build 启用 Proguard。如需为调试 build 启用实验性缩减器,请将以下代码添加到模块级
build.gradle
文件中:
android {
...
buildTypes {
debug {
minifyEnabled true
useProguard false
}
release {
minifyEnabled true
useProguard true // this is a default setting
}
}
}
android {
...
buildTypes {
getByName("debug") {
minifyEnabled = true
useProguard = false
}
getByName("release") {
minifyEnabled = true
useProguard = true // this is a default setting
}
}
}
- 为资源缩减器添加了日志记录支持并提升了性能。资源压缩器现在会将其所有操作记录到与 Proguard 日志文件位于同一文件夹的
resources.txt
文件中。
- 改变的行为:
-
- 修复的问题:
-
- 修复了导致在测试和主 build 配置中出现重复 AAR 依赖项的问题。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-30。
[null,null,["最后更新时间 (UTC):2025-08-30。"],[],[],null,["\u003cbr /\u003e\n\nAndroid Gradle Plugin 2.0.0 (April 2016)\n\n\u003cbr /\u003e\n\nDependencies:\nNew:\n:\n - Enables [Instant Run](/tools/building/building-studio#instant-run) by supporting bytecode injection, and pushing code and resource updates to a running app on the emulator or a physical device.\n - Added support for incremental builds, even when the app isn't running. Full build times are improved by pushing incremental changes through the [Android Debug Bridge](/tools/help/adb) to the connected device.\n - Added [`maxProcessCount`](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.DexOptions.html#com.android.build.gradle.internal.dsl.DexOptions:maxProcessCount) to control how many worker dex processes can be spawned concurrently. The following code, in the module-level `build.gradle` file, sets the maximum number of concurrent processes to 4: \n\n Groovy \n\n ```groovy\n android {\n ...\n dexOptions {\n maxProcessCount = 4 // this is the default value\n }\n }\n ```\n\n Kotlin \n\n ```kotlin\n android {\n ...\n dexOptions {\n maxProcessCount = 4 // this is the default value\n }\n }\n ```\n - Added an experimental code shrinker to support pre-dexing and reduce re-dexing of dependencies, which are not supported with Proguard. This improves the build speed of your debug build variant. Because the experimental shrinker does not support optimization and obfuscation, you should enable Proguard for your release builds. To enable the experimental shrinker for your debug builds, add the following to your module-level `build.gradle` file: \n\n Groovy \n\n ```groovy\n android {\n ...\n buildTypes {\n debug {\n minifyEnabled true\n useProguard false\n }\n release {\n minifyEnabled true\n useProguard true // this is a default setting\n }\n }\n }\n ```\n\n Kotlin \n\n ```kotlin\n android {\n ...\n buildTypes {\n getByName(\"debug\") {\n minifyEnabled = true\n useProguard = false\n }\n getByName(\"release\") {\n minifyEnabled = true\n useProguard = true // this is a default setting\n }\n }\n }\n ```\n - Added logging support and improved performance for the resource shrinker. The resource shrinker now logs all of its operations into a `resources.txt` file located in the same folder as the Proguard log files.\n\nChanged behavior:\n:\n - When `minSdkVersion` is set to 18 or higher, APK signing uses SHA256.\n - DSA and ECDSA keys can now sign APK packages.\n **Note:** The [Android keystore](/training/articles/keystore) provider no\n longer supports [DSA keys on Android 6.0](/about/versions/marshmallow/android-6.0-changes#behavior-keystore) (API level 23) and higher.\n\n\nFixed issues:\n:\n - Fixed an issue that caused duplicate AAR dependencies in both the test and main build configurations."]]