自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
整合未綁定的應用程式
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
包含撥號、媒體、Car UI 程式庫和 SMS 的應用程式視為未內含套件的應用程式 (也就是從 Android 平台中未內含套件)。這類應用程式包含從手機隨附應用程式接收資料的邏輯,以及汽車端的使用者體驗,包括關聯和功能註冊設定。使用未內含的程式碼建構的 APK 可與多個平台版本搭配運作。
查看程式碼
如要檢查未內含的程式碼,請執行以下指令:
repo init -u https://android.googlesource.com/platform/manifest -b ub-automotive-master
repo sync -cq -j4
如要進一步瞭解如何使用 AOSP 原始碼,請參閱「初始化 Repo 用戶端」一文。
建構程式碼
您可以使用 Android Studio 或指令列建構程式碼。
Android Studio
如要在 Android Studio 中建構程式碼,請按照下列步驟操作:
在 Android Studio 中匯入下列建構檔案:
packages/apps/Car/libs/aaos-apps-gradle-project/build.gradle
確認 Gradle JDK 已設為 11 以上版本:
圖 1. 在 Android Studio 中將 Gradle JDK 設為 11 版。
指令列
如何透過指令列建構程式碼:
請使用下列任一方法設定 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 的路徑。
開啟命令提示字元或殼層視窗。
前往 packages/apps/Car/libs/aaos-apps-gradle-project
。
執行下列指令:
./gradlew assemble
最低 API 級別要求
每個未綁定的應用程式都能在 Android 平台上運作,且版本必須與其 minSdkVersion
相同或更高。下表列出各應用程式支援的最低 API 版本:
應用程式 |
最低 API 級別 |
日曆 |
29 |
Car UI 程式庫 |
29 |
CompanionDevice |
29 |
Dialer |
31 |
媒體 |
30 |
Messenger (簡訊) |
30 |
Android 開放原始碼計畫主機 |
29 |
將預先建構的映像檔整合至系統映像檔
如果應用程式支援 Android 平台版本 (請參閱上一節的資料表),您可以將 APK 新增至系統映像檔。不過,Android 平台版本的整合步驟有所不同。
Android 13 以上版本
Android 13 以上版本不包含未內含套件的應用程式原始碼,但您可以在平台版本中加入預先建構的 APK,用於 CDD 法規遵循測試或佈建特權應用程式等用途。如要指定 APK,請使用 android_app_import
Song 規則,如以下範例所示:
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 預設會將優先順序給予來源程式碼,而非預先建構的程式碼,因此必須在 android_app_import
規則中將 prefer
標記設為 true
,如以下範例所示:
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
}
未內含的應用程式詳細資料
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-06-12 (世界標準時間)。
[[["容易理解","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 (世界標準時間)。"],[],[],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 |"]]