จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ปลั๊กอิน Android สำหรับ Gradle ฉบับแก้ไข 1.3.0 (กรกฎาคม 2015)
การขึ้นต่อกัน:
|
เวอร์ชันขั้นต่ำ |
เวอร์ชันเริ่มต้น |
หมายเหตุ |
Gradle |
2.2.1 |
2.2.1 |
ดูข้อมูลเพิ่มเติมได้ที่การอัปเดต Gradle |
เครื่องมือสร้าง SDK |
21.1.1 |
21.1.1 |
ติดตั้งหรือกำหนดค่าเครื่องมือสร้าง SDK |
หมายเหตุทั่วไป:
-
เพิ่มการรองรับพร็อพเพอร์ตี้ com.android.build.threadPoolSize
เพื่อควบคุมขนาดพูลเธรดของงาน Android
จาก
ไฟล์ gradle.properties
หรือบรรทัดคำสั่ง ตัวอย่างต่อไปนี้ตั้งค่าพร็อพเพอร์ตี้นี้เป็น 4
-Pcom.android.build.threadPoolSize=4
- ตั้งค่าลักษณะการทำงานของการบิลด์เริ่มต้นเพื่อยกเว้นไฟล์
LICENSE
และ LICENSE.txt
จาก APK หากต้องการรวมไฟล์เหล่านี้ไว้ใน APK ให้นำไฟล์เหล่านี้ออกจากพร็อพเพอร์ตี้
packagingOptions.excludes
ในไฟล์ build.gradle
เช่น
android {
packagingOptions.excludes = []
}
android {
packagingOptions.excludes.clear()
}
- เพิ่ม
sourceSets
งานเพื่อตรวจสอบชุดแหล่งที่มาทั้งหมดที่ใช้ได้
- การรองรับการทดสอบหน่วยที่ได้รับการปรับปรุงเพื่อจดจำโฟลเดอร์แหล่งที่มาของหลายรสชาติและ
ตัวแปรบิลด์ ตัวอย่างเช่น หากต้องการทดสอบแอปที่มีหลายรสชาติ
flavor1
และ flavorA
ที่มีDebug
ประเภทบิลด์
ชุดแหล่งที่มาของการทดสอบจะเป็นดังนี้
- ทดสอบ
- testFlavor1
- testFlavorA
- testFlavor1FlavorA
- testFlavor1FlavorADebug
การทดสอบ Android รับรู้โฟลเดอร์แหล่งที่มาหลายรสชาติอยู่แล้ว
- ปรับปรุงการรองรับการทดสอบหน่วยเพื่อทำสิ่งต่อไปนี้
- เรียกใช้
javac
ในแหล่งที่มาหลักและแหล่งที่มาทดสอบ แม้ว่าจะตั้งค่าพร็อพเพอร์ตี้ useJack
เป็น true
ในไฟล์บิลด์ก็ตาม
- รู้จักทรัพยากร Dependency อย่างถูกต้องสำหรับบิลด์แต่ละประเภท
- เพิ่มการรองรับการระบุอาร์กิวเมนต์ของโปรแกรมเรียกใช้การทดสอบเครื่องมือจากบรรทัดคำสั่ง
เช่น
./gradlew connectedCheck
-Pandroid.testInstrumentationRunnerArguments.size=medium
-Pandroid.testInstrumentationRunnerArguments.class=TestA,TestB
เพิ่มการรองรับพารามิเตอร์เพิ่มเติมของเครื่องมือการแพ็กเกจชิ้นงาน Android (AAPT)
ในไฟล์ build.gradle
เช่น
android {
aaptOptions {
additionalParameters "--custom_option", "value"
}
}
android {
aaptOptions {
additionalParameters += listOf("--custom_option", "value")
}
}
- เพิ่มการรองรับ
โมดูล APK ทดสอบเป็นโมดูลทดสอบแยกต่างหาก โดยใช้พร็อพเพอร์ตี้
targetProjectPath
และ targetVariant
เพื่อตั้งค่าเส้นทาง APK
และตัวแปรเป้าหมาย
หมายเหตุ: โมดูล APK ทดสอบไม่รองรับ Product
Flavors และกำหนดเป้าหมายได้เฉพาะตัวแปรเดียว นอกจากนี้ ระบบยังไม่รองรับ Jacoco
- เพิ่มการตรวจสอบชื่อทรัพยากรก่อนผสานทรัพยากร
- เมื่อสร้างแพ็กเกจ AAR (Android ARchive) สำหรับโมดูลไลบรารี อย่าระบุตัวยึดตำแหน่งอัตโนมัติ
@{applicationId}
ในการตั้งค่าการผสานไฟล์ Manifest
ให้ใช้ตัวยึดตำแหน่งอื่นแทน เช่น @{libApplicationId}
และ
ระบุค่าสำหรับตัวยึดตำแหน่งนั้นหากต้องการรวมรหัสแอปพลิเคชันไว้ในคลังที่เก็บถาวร
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-30 UTC
[null,null,["อัปเดตล่าสุด 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"]]