ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
ผสานรวมแอปที่ไม่ได้รวมกลุ่ม
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
แอปที่มีโปรแกรมโทรศัพท์ สื่อ ไลบรารี UI ของรถ และ SMS จะถือว่าไม่ได้รวมอยู่ในแพ็กเกจ (กล่าวคือไม่ได้รวมอยู่ในแพ็กเกจของแพลตฟอร์ม Android) แอปดังกล่าวมีตรรกะในการรับข้อมูลจากแอปที่ใช้ร่วมกันบนโทรศัพท์และ UX ฝั่งรถยนต์ รวมถึงการตั้งค่าการเชื่อมโยงและการลงทะเบียนฟีเจอร์ APK ที่สร้างขึ้นจากโค้ดแบบไม่ได้รวมกลุ่มจะทำงานร่วมกับแพลตฟอร์มหลายเวอร์ชันได้
ดูรหัส
หากต้องการตรวจสอบรหัสที่แยกออกมาแล้ว ให้เรียกใช้คำสั่งต่อไปนี้
repo init -u https://android.googlesource.com/platform/manifest -b ub-automotive-master
repo sync -cq -j4
ดูข้อมูลเพิ่มเติมเกี่ยวกับการใช้งานซอร์สโค้ด AOSP ได้ที่เริ่มต้นใช้งาน Repo
Client
บิลด์โค้ด
คุณสร้างโค้ดได้โดยใช้ Android Studio หรือจากบรรทัดคำสั่ง
Android Studio
วิธีสร้างโค้ดใน Android Studio
ใน Android Studio ให้นําเข้าไฟล์บิลด์ต่อไปนี้
packages/apps/Car/libs/aaos-apps-gradle-project/build.gradle
ตรวจสอบว่าได้ตั้งค่า Gradle JDK เป็นเวอร์ชัน 11 ขึ้นไปแล้ว โดยทำดังนี้
รูปที่ 1 ตั้งค่า Gradle JDK เป็นเวอร์ชัน 11 ใน Android Studio
บรรทัดคำสั่ง
วิธีสร้างโค้ดจากบรรทัดคำสั่ง
ตั้งค่าตำแหน่ง Android SDK โดยใช้วิธีใดวิธีหนึ่งต่อไปนี้
สร้าง packages/apps/Car/libs/aaos-apps-gradle-project/local.properties
แล้วตั้งค่าพร็อพเพอร์ตี้ sdk.dir
ที่มี Android Studio สามารถทำการดำเนินการนี้โดยอัตโนมัติเมื่อเปิดโปรเจ็กต์ เช่น ใช้
sdk.dir=/Users/MY-USERNAME/Library/Android/sdk
หรือ
ตั้งค่าตัวแปรสภาพแวดล้อม ANDROID_SDK_ROOT
ด้วยเส้นทางไปยัง Android SDK
เปิด Command Prompt หรือหน้าต่างเชลล์
ไปที่packages/apps/Car/libs/aaos-apps-gradle-project
เรียกใช้คําสั่งต่อไปนี้
./gradlew assemble
ระดับ API ขั้นต่ำที่ต้องการ
แอปที่แยกออกมาแต่ละแอปจะใช้งานได้บนแพลตฟอร์ม Android ที่มีเวอร์ชันเท่ากับหรือมากกว่าminSdkVersion
ของแอป ตารางต่อไปนี้แสดงเวอร์ชัน API ขั้นต่ำที่แอปแต่ละแอปรองรับ
แอป |
ระดับ API ขั้นต่ำ |
ปฏิทิน |
29 |
ไลบรารี UI ของรถ |
29 |
CompanionDevice |
29 |
Dialer |
31 |
สื่อ |
30 |
Messenger (SMS) |
30 |
โฮสต์ AOSP |
29 |
ผสานรวมรุ่นที่สร้างไว้ล่วงหน้าลงในอิมเมจระบบ
หากแอปรองรับเวอร์ชันแพลตฟอร์ม Android (ดูตารางในส่วนก่อนหน้า) คุณสามารถเพิ่ม APK ลงในอิมเมจระบบได้ อย่างไรก็ตาม ขั้นตอนในการผสานรวมจะแตกต่างกันไปตามเวอร์ชันแพลตฟอร์ม Android
Android 13 ขึ้นไป
Android 13 ขึ้นไปจะไม่มีซอร์สโค้ดสําหรับแอปที่แยกออกมา แต่คุณสามารถใส่ APK ที่คอมไพล์ไว้ล่วงหน้าในบิลด์แพลตฟอร์มสําหรับกรณีการใช้งานต่างๆ เช่น การทดสอบการปฏิบัติตามข้อกําหนด CDD หรือการจัดสรรแอปที่มีสิทธิ์ หากต้องการระบุ APK ให้ใช้กฎ android_app_import
ของ Soong ดังที่แสดงในตัวอย่างต่อไปนี้
android_app_import {
name: "CarMediaApp",
apk: "CarMediaApp.apk",
privileged: true,
certificate: "platform", // Media must be signed by the platform
required: ["allowed_privapp_com.android.car.media"],
}
Android 12 และต่ำกว่า
Android 12 และต่ำกว่าจะมีซอร์สโค้ดสําหรับแอปที่ไม่ได้รวมกลุ่ม แต่คุณยังคงระบุ APK ที่คอมไพล์ไว้ล่วงหน้าเพื่อรวมไว้ได้ เนื่องจากค่าเริ่มต้นของ Soong คือการให้ความสำคัญกับซอร์สโค้ดมากกว่าที่คอมไพล์ไว้ล่วงหน้า คุณจึงต้องตั้งค่า Flag prefer
เป็น true
ภายในกฎ android_app_import
ดังที่แสดงในตัวอย่างต่อไปนี้
android_app_import {
name: "CarDialerApp",
apk: "CarDialerApp.apk",
privileged: true,
presigned: true, // Dialer can have its own signature
required: ["allowed_privapp_com.android.car.dialer"],
overrides: ["Dialer"],
prefer: true, // The prebuilt replaces a source target with the same name
}
รายละเอียดแอปที่แยกออกมา
แอป/การจัดจำหน่าย |
สิทธิ์ที่ยกเลิกการรวม ระบบ
ลงนาม |
ไม่ได้รวมกลุ่มที่มีสิทธิ์ ไม่ได้ลงนามในระบบ |
ไม่ได้รวมกลุ่ม ไม่จําเป็นต้องอยู่ในพาร์ติชันระบบ |
แอป -
ปฏิทิน
|
|
|
X |
แอป -
CompanionDeviceSupport
|
|
X |
|
แอป -
Dialer
|
|
X |
|
แอป - โฮสต์ AOSP |
|
X |
|
แอป -
สื่อ |
X |
|
|
แอป -
Messenger
(SMS) |
|
X |
|
อัปเดตการเผยแพร่ |
OTA |
OTA หรือ Google Play |
OTA หรือ Google Play |
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-06-12 UTC
[[["เข้าใจง่าย","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-06-12 UTC"],[],[],null,["# Integrate unbundled apps\n\nApps that include Dialer, Media, Car UI Library, and SMS are considered\n*unbundled apps* (that is, they are unbundled from the Android platform). Such\napps include the logic for receiving data from the phone companion app and UX on\nthe car side, including settings for association and feature enrollment. APKs\nbuilt from unbundled code work with several versions of the platform.\n\nCheck out the code\n------------------\n\nTo check out the unbundled code, run the following: \n\n repo init -u https://android.googlesource.com/platform/manifest -b ub-automotive-master\n repo sync -cq -j4\n\nTo learn more about working with AOSP source code, see [Initialize the Repo\nClient](/setup/download#initialize_the_repo_client).\n\nBuild the code\n--------------\n\nYou can build the code using Android Studio or from the command line.\n\n### Android Studio\n\nTo build the code in Android Studio:\n\n1. In Android Studio, import the following build file:\n\n packages/apps/Car/libs/aaos-apps-gradle-project/build.gradle\n\n2. Ensure the Gradle JDK is set to Version 11 or higher:\n\n **Figure 1.** Set Gradle JDK to Version 11 in Android Studio.\n\n### Command line\n\nTo build the code from the command line:\n\n1. Set the Android SDK location using one of the following methods:\n\n - Create\n `packages/apps/Car/libs/aaos-apps-gradle-project/local.properties` and\n then set the `sdk.dir` property it contains. Android Studio can do this\n automatically when opening a project. For example, use\n `sdk.dir=/Users/MY-USERNAME/Library/Android/sdk`.\n\n *or*\n - Set the `ANDROID_SDK_ROOT` environment variable with the path to the\n Android SDK.\n\n2. Open a command prompt or a shell window.\n\n3. Go to `packages/apps/Car/libs/aaos-apps-gradle-project`.\n\n4. Run the following command:\n\n ./gradlew assemble\n\nMinimum required API levels\n---------------------------\n\nEach unbundled app works on Android platforms with a version equal to or greater\nthan its\n[`minSdkVersion`](https://developer.android.com/studio/publish/versioning). The\nfollowing table lists the minimum API version supported by each app:\n\n| App | Minimum API level |\n|---------------------------------------------|-------------------|\n| Calendar | 29 |\n| Car UI library | 29 |\n| CompanionDevice | 29 |\n| Dialer | 31 |\n| Media | 30 |\n| Messenger (SMS) | 30 |\n| [AOSP Host](/docs/automotive/hmi/aosp_host) | 29 |\n\nIntegrate a prebuild into a system image\n----------------------------------------\n\nIf the Android platform version is supported by the app (see the table in the\nprevious section), you can add the APK to the system image. However, the\nintegration steps differ between Android platform versions.\n\n### Android 13 and higher\n\nAndroid 13 and higher doesn't include source code for unbundled apps, but you\ncan include a prebuilt APK in the platform build for use cases such as CDD\ncompliance testing or provisioning privileged apps. To specify the APK, use the\n[`android_app_import`](https://ci.android.com/builds/latest/branches/aosp-build-tools/targets/linux/view/soong_build.html)\nSoong rule, as shown in the following example: \n\n android_app_import {\n name: \"CarMediaApp\",\n apk: \"CarMediaApp.apk\",\n privileged: true,\n certificate: \"platform\", // Media must be signed by the platform\n required: [\"allowed_privapp_com.android.car.media\"],\n }\n\n### Android 12 and lower\n\nAndroid 12 and lower includes source code for unbundled apps, but you can still\nspecify a prebuilt APK to include. Because the Soong default is to give\nprecedence to the source code over a prebuilt, it's necessary to set the\n`prefer` flag to `true` inside the `android_app_import` rule, as shown in the\nfollowing example: \n\n android_app_import {\n name: \"CarDialerApp\",\n apk: \"CarDialerApp.apk\",\n privileged: true,\n presigned: true, // Dialer can have its own signature\n required: [\"allowed_privapp_com.android.car.dialer\"],\n overrides: [\"Dialer\"],\n prefer: true, // The prebuilt replaces a source target with the same name\n }\n\nUnbundled app details\n---------------------\n\n| App/Distribution | Privileged unbundled *system signed* | Privileged unbundled *non-system signed* | Unbundled *don't need to be on system partition* |\n|------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------|------------------------------------------|--------------------------------------------------|\n| App - [Calendar](https://android.googlesource.com/platform/packages/apps/Car/Calendar/+/refs/heads/mirror-car-apps-aosp-release) | | | X |\n| App - [CompanionDeviceSupport](https://android.googlesource.com/platform/packages/apps/Car/CompanionDeviceSupport/+log/refs/heads/main) | | X | |\n| App - [Dialer](https://android.googlesource.com/platform/packages/apps/Car/Dialer/+/refs/heads/mirror-car-apps-aosp-release) | | X | |\n| App - AOSP Host | | X | |\n| App - [Media](https://android.googlesource.com/platform/packages/apps/Car/Media/+/refs/heads/mirror-car-apps-aosp-release) | X | | |\n| App - [Messenger (SMS)](https://android.googlesource.com/platform/packages/apps/Car/Messenger/+/refs/heads/mirror-car-apps-aosp-release) | | X | |\n| Update distribution | OTA | OTA or Google Play | OTA or Google Play |"]]