自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
集成未捆绑的应用
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
拨号器、媒体、车载设备界面库和短信等应用被视为未捆绑应用(即,这些应用未与 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 中,导入以下 build 文件:
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 的路径设置 ANDROID_SDK_ROOT
环境变量。
打开命令提示符或 shell 窗口。
前往“packages/apps/Car/libs/aaos-apps-gradle-project
”。
运行以下命令:
./gradlew assemble
所需的最低 API 级别
每个未捆绑应用都可以在版本不低于其 minSdkVersion
的 Android 平台上运行。下表列出了每个应用支持的最低 API 版本:
应用 |
最低 API 级别 |
日历 |
29 |
车载设备界面库 |
29 |
CompanionDevice |
29 |
Dialer |
31 |
媒体 |
30 |
Messenger(短信) |
30 |
AOSP 主机 |
29 |
将预构建 build 集成到系统映像中
如果应用支持相应 Android 平台版本(请参阅上一部分中的表格),您可以将 APK 添加到系统映像中。不过,集成步骤会因 Android 平台版本而异。
Android 13 及更高版本
Android 13 及更高版本不包含未捆绑应用的源代码,但您可以在平台 build 中添加预构建的 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 默认会为源代码提供高于预构建项的优先级,因此需要在 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 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-17。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-03-17。"],[],[],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 |"]]