透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android Gradle 外掛程式 2.0.0 版 (2016 年 4 月)
- 依附元件:
|
最低版本 |
預設版本 |
附註 |
Gradle |
2.10 |
2.10 |
詳情請參閱「更新 Gradle」一節。 |
SDK 版本工具 |
21.1.1 |
21.1.1 |
安裝或設定 SDK 版本工具。 |
- 新功能:
-
- 透過支援位元碼插入,以及將更新的程式碼和資源推送到在模擬器或實體裝置上正在執行的應用程式,啟用立即執行功能。
- 新增對漸進式建構作業的支援功能,無論應用程式是否正在執行都能順利運作。將漸進式變更內容透過 Android Debug Bridge 推送到已連結的裝置上,藉此縮短整體建構時間。
- 新增
maxProcessCount
,以便控管同時可以產生的工作站 DEX 程序數量。下列程式碼位於模組層級 build.gradle
檔案內,將並行程序上限設定為 4:
Groovy
android {
...
dexOptions {
maxProcessCount = 4 // this is the default value
}
}
Kotlin
android {
...
dexOptions {
maxProcessCount = 4 // this is the default value
}
}
- 新增實驗性的程式碼縮減器,以便進行 DEX 前置處理並減少對依附元件的 DEX 重新處理,這些是 ProGuard 未支援的功能。這樣做可以改善偵錯版本變化的建構速度。由於實驗性的縮減器並不支援最佳化和模糊化,因此您的發布子版本應啟用 Proguard。若要為您的偵錯版本啟用實驗性縮減器,請在模組層級
build.gradle
檔案中加入以下內容:
Groovy
android {
...
buildTypes {
debug {
minifyEnabled true
useProguard false
}
release {
minifyEnabled true
useProguard true // this is a default setting
}
}
}
Kotlin
android {
...
buildTypes {
getByName("debug") {
minifyEnabled = true
useProguard = false
}
getByName("release") {
minifyEnabled = true
useProguard = true // this is a default setting
}
}
}
- 新增資源縮減器的記錄支援功能,並改善效能。資源縮減器現在會將所有操作記錄為
resources.txt
檔案,位於和 Proguard 記錄檔案相同的資料夾內。
- 變更行為:
-
- 修正問題:
-
- 修正導致同時在測試和主要建構設定中複製 AAR 依附元件的問題。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-08-30 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間: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."]]