Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trình bổ trợ Android cho Gradle 2.0.0 (tháng 4 năm 2016)
- Phần phụ thuộc:
|
Phiên bản tối thiểu |
Phiên bản mặc định |
Lưu ý |
Gradle |
2.10 |
2.10 |
Để tìm hiểu thêm, hãy xem phần cập nhật Gradle. |
Công cụ tạo SDK |
21.1.1 |
21.1.1 |
Cài đặt hoặc định cấu hình Công cụ tạo SDK. |
- Mới:
-
- Bật tính năng Chạy tức thì bằng cách
hỗ trợ tính năng chèn mã byte, đồng thời đẩy nhanh các bản cập nhật mã và tài nguyên vào
ứng dụng đang chạy trên trình mô phỏng hoặc thiết bị thực tế.
- Thêm tính năng hỗ trợ các bản dựng gia tăng, ngay cả khi ứng dụng không chạy.
Cải thiện thời gian tạo bản dựng đầy đủ bằng cách đẩy những thay đổi gia tăng qua Cầu gỡ lỗi Android đến thiết bị được kết nối.
- Bổ sung
maxProcessCount
để điều khiển số lượng trình chạy quy trình dex có thể được sinh ra cùng lúc. Mã sau đây trong tệp build.gradle
ở cấp mô-đun thiết lập số lượng quy trình đồng thời tối đa
thành 4:
Groovy
android {
...
dexOptions {
maxProcessCount = 4 // this is the default value
}
}
Kotlin
android {
...
dexOptions {
maxProcessCount = 4 // this is the default value
}
}
- Thêm một trình rút gọn mã thử nghiệm hỗ trợ chuyển sang định dạng .dex và giảm hiện tượng lặp lại các phần phụ thuộc mà Proguard không hỗ trợ. Cách này giúp tăng tốc độ của biến thể bản dựng gỡ lỗi. Do trình rút gọn mã thử nghiệm không hỗ trợ tính năng tối ưu hoá và làm rối mã nguồn, bạn nên bật Proguard cho các bản dựng phát hành. Để bật trình rút gọn mã thử nghiệm cho bản dựng gỡ lỗi, hãy thêm đoạn mã sau vào tệp
build.gradle
cấp mô-đun:
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
}
}
}
- Thêm tính năng hỗ trợ ghi nhật ký và cải thiện hiệu suất cho trình thu gọn tài nguyên.
Trình thu gọn tài nguyên nay ghi lại tất cả hoạt động vào tệp
resources.txt
nằm trong cùng thư mục với tệp nhật ký Proguard.
- Thay đổi hành vi
-
- Sửa các vấn đề:
-
- Sửa vấn đề gây trùng lặp các phần phụ thuộc AAR trong cả cấu hình bản dựng kiểm thử lẫn bản dựng chính.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-08-30 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-30 UTC."],[],[],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."]]