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, bản sửa đổi 1.3.0 (Tháng 7 năm 2015)
Phần phụ thuộc:
|
Phiên bản tối thiểu |
Phiên bản mặc định |
Lưu ý |
Gradle |
2.2.1 |
2.2.1 |
Để 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. |
Lưu ý chung:
-
Thêm tính năng hỗ trợ cho thuộc tính com.android.build.threadPoolSize
để điều khiển kích thước nhóm luồng tác vụ Android
từ tệp gradle.properties
hoặc dòng lệnh. Ví dụ sau đây đặt giá trị thuộc tính này là 4.
-Pcom.android.build.threadPoolSize=4
- Đặt hành vi mặc định của bản dựng để loại trừ các tệp
LICENSE
và LICENSE.txt
khỏi APK. Để đưa những tệp này vào APK, hãy xoá chúng khỏi thuộc tính packagingOptions.excludes
trong tệp build.gradle
.
Ví dụ:
android {
packagingOptions.excludes = []
}
android {
packagingOptions.excludes.clear()
}
- Bổ sung tác vụ của
sourceSets
để kiểm tra tập hợp các nhóm tài nguyên có sẵn.
- Hỗ trợ nâng cao bài kiểm thử đơn vị để nhận ra các thư mục nguồn đa phiên bản và thư mục nguồn biến thể bản dựng. Ví dụ: để kiểm thử một ứng dụng có nhiều phiên bản
flavor1
và flavorA
bằng loại bản dựng Debug
, thì các nhóm tài nguyên kiểm thử sẽ là:
- test
- testFlavor1
- testFlavorA
- testFlavor1FlavorA
- testFlavor1FlavorADebug
Các kiểm thử Android đã nhận dạng được các thư mục nguồn nhiều phiên bản.
- Cải thiện khả năng hỗ trợ kiểm thử đơn vị cho:
- Hãy chạy
javac
trên các nguồn chính và nguồn kiểm thử, ngay cả khi thuộc tính useJack
được thiết lập thành true
trong tệp bản dựng.
- Nhận dạng chính xác các phần phụ thuộc cho từng loại bản dựng.
- Hỗ trợ thêm tính năng chỉ định đối số chạy kiểm thử đo lường từ dòng lệnh.
Ví dụ:
./gradlew connectedCheck
-Pandroid.testInstrumentationRunnerArguments.size=medium
-Pandroid.testInstrumentationRunnerArguments.class=TestA,TestB
Hỗ trợ thêm các thông số bổ sung tuỳ ý của Công cụ đóng gói tài nguyên Android (AAPT) trong tệp build.gradle
. Ví dụ:
android {
aaptOptions {
additionalParameters "--custom_option", "value"
}
}
android {
aaptOptions {
additionalParameters += listOf("--custom_option", "value")
}
}
- Hỗ trợ thêm mô-đun APK kiểm thử dưới dạng mô-đun kiểm thử riêng biệt, sử dụng các thuộc tính
targetProjectPath
và targetVariant
để đặt đường dẫn APK và biến thể mục tiêu.Lưu ý: Mô-đun APK kiểm thử không hỗ trợ phiên bản sản phẩm và chỉ có thể nhắm mục tiêu một biến thể duy nhất. Ngoài ra, Jacoco chưa được hỗ trợ.
- Bổ sung tính năng xác thực tên tài nguyên trước khi hợp nhất các tài nguyên.
- Khi xây dựng gói AAR (Android ARchive) cho các mô-đun thư viện, bạn không nên cung cấp phần giữ chỗ
@{applicationId}
tự động trong cài đặt trình hợp nhất tệp kê khai.
Thay vào đó, hãy sử dụng một phần giữ chỗ khác, chẳng hạn như @{libApplicationId}
và cung cấp giá trị cho phần giữ chỗ đó nếu bạn muốn đưa các mã ứng dụng vào thư viện lưu trữ.
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 plugin for Gradle, revision 1.3.0 (July 2015)\n\n**Dependencies:**\n\n| | Minimum version | Default version | Notes |\n|----------------:|:---------------:|:---------------:|:----------------------------------------------------------------------------------------------------------:|\n| Gradle | 2.2.1 | 2.2.1 | To learn more, see [updating Gradle](/build/releases/gradle-plugin?buildsystem=ndk-build#updating-gradle). |\n| SDK Build Tools | 21.1.1 | 21.1.1 | [Install](/studio/intro/update#sdk-manager) or [configure](/tools/releases/build-tools) SDK Build Tools. |\n\n**General Notes:**\n\n- Added support for the `com.android.build.threadPoolSize`\n property to control the `Android` task thread pool size from\n the `gradle.properties` file or the command line. The\n following example sets this property to 4.\n\n \n -Pcom.android.build.threadPoolSize=4\n \n \n- Set the default build behavior to exclude `LICENSE` and `LICENSE.txt` files from APKs. To include these files in an APK, remove these files from the `packagingOptions.excludes` property in the `build.gradle` file. For example: \n\n ```groovy\n android {\n packagingOptions.excludes = []\n }\n \n ``` \n\n ```kotlin\n android {\n packagingOptions.excludes.clear()\n }\n \n ```\n- Added the `sourceSets` task to inspect the set of all available source sets.\n- Enhanced unit test support to recognize multi-flavor and [build variant](/tools/building/configuring-gradle#workBuildVariants) source folders. For example, to test an app with multi-flavors `flavor1` and `flavorA` with the `Debug` build type, the test source sets are:\n - test\n - testFlavor1\n - testFlavorA\n - testFlavor1FlavorA\n - testFlavor1FlavorADebug\n\n Android tests already recognized multi-flavor source folders.\n- Improved unit test support to:\n - Run `javac` on main and test sources, even if the `useJack` property is set to `true` in your build file.\n - Correctly recognize dependencies for each build type.\n- Added support for specifying instrumentation test-runner arguments from the command line. For example: \n\n ```\n ./gradlew connectedCheck \n\n -Pandroid.testInstrumentationRunnerArguments.size=medium \n\n -Pandroid.testInstrumentationRunnerArguments.class=TestA,TestB\n \n ```\n- Added support for arbitrary additional Android Asset Packaging Tool (AAPT) parameters\n in the `build.gradle` file. For example:\n\n ```groovy\n android {\n aaptOptions {\n additionalParameters \"--custom_option\", \"value\"\n }\n }\n \n ``` \n\n ```kotlin\n android {\n aaptOptions {\n additionalParameters += listOf(\"--custom_option\", \"value\")\n }\n }\n \n ```\n- Added support for a [test APK module](/tools/studio/studio-features#test-module) as a separate test module, using the `targetProjectPath` and `targetVariant` properties to set the APK path and target variant.\n\n **Note:** A test APK module does not support product\n flavors and can only target a single variant. Also, Jacoco is not supported yet.\n- Added resource name validation before merging resources.\n- When building an AAR (Android ARchive) package for library modules, do not provide an automatic `@{applicationId}` placeholder in the [manifest merger](/tools/building/manifest-merge) settings. Instead, use a different placeholder, such as `@{libApplicationId}` and provide a value for it if you want to include application Ids in the archive library.\n\n\u003cbr /\u003e"]]