Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release thay vì aosp-main để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
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.
Dự án nguồn mở Android (AOSP) Automotive App Host là một phần của Thư viện ứng dụng ô tô mà các nhà phát triển bên thứ ba (3P) sử dụng để bật ứng dụng cho Android Automotive. Máy chủ ứng dụng là một ứng dụng hệ thống cho phép các ứng dụng ô tô của bên thứ ba thay mặt hiển thị các thành phần giao diện người dùng (UI) theo kiểu OEM.
Để chạy ứng dụng bên thứ ba, bạn phải cài đặt cả ứng dụng bên thứ ba và Máy chủ lưu trữ ứng dụng ô tô AOSP:
Automotive App Host cung cấp cho các ứng dụng bên thứ ba một bộ mẫu giao diện người dùng và các thành phần được tối ưu hoá cho xe, bao gồm cả các tính năng như khả năng hữu dụng và an toàn.
Nhà sản xuất thiết bị gốc (OEM) có thể tạo kiểu cho các mẫu và thành phần giao diện người dùng này.
Kết quả là gì? Ứng dụng bên thứ ba được tích hợp hiệu quả vào hệ thống thông tin giải trí của nhà sản xuất thiết bị gốc (OEM).
Trang này giải thích cách tạo Máy chủ ứng dụng ô tô AOSP từ dự án Gradle trong nhánh ub-automotive, sau đó cách tích hợp Máy chủ ứng dụng ô tô AOSP vào mục tiêu ô tô.
Xem ub-automotive rồi mở dự án Gradle trong packages/apps/Car/Templates/Host.
Để định cấu hình dự án bằng SDK Android, hãy định cấu hình tệp local.properties của dự án. Bạn có thể tìm thấy đường dẫn này trong phần Cài đặt SDK Android trong Android Studio.
sdk.dir=${path_to_android_sdk_location}
Tạo tệp APK lưu trữ dưới dạng một dự án Gradle thông thường. Ví dụ: chạy lệnh gradle:
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-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# AOSP host integration guide\n\nThe Android Open Source Project (AOSP) Automotive App Host is a part of the Car App Library\nused by third-party (3P) developers to enable apps for Android Automotive. The App Host is a system\napp that allows 3P car apps to render OEM-styled user interface (UI) components on its behalf.\n\nTo run 3P apps, both the 3P app and the AOSP Automotive App Host must be\ninstalled:\n\n- Automotive App Host provides 3P apps with a a set of UI templates and components optimized for vehicles, including capabilities like usability and safety.\n- OEMs can style these UI templates and components.\n- **The result?** 3P apps are visually well-integrated into the infotainment system of the OEM.\n\nThis page explains how to generate the AOSP Automotive App Host from the Gradle project in the\n`ub-automotive` branch and then how to integrate the AOSP Automotive App Host into car\ntargets.\n\nCheck out the code\n------------------\n\nTo check out the unbundled code:\n\n1. Run the following command: \n\n ```text\n repo init -u https://android.googlesource.com/platform/manifest -b ub-automotive-master\n repo sync -j4\n ```\n2. To learn more about working with AOSP source code, see\n [Initialize a Repo client](/docs/setup/download/downloading#initializing-a-repo-client).\n\n3. Install [Android Studio](https://developer.android.com/studio).\n\nCreate the AOSP host APK\n------------------------\n\n1. Check out `ub-automotive` and then open the Gradle project under `packages/apps/Car/Templates/Host`.\n2. To configure the project with the Android SDK, configure your project's `local.properties` file. You can find the path under Android SDK Settings in Android Studio. \n\n ```genshi\n sdk.dir=${path_to_android_sdk_location}\n ```\n3. Create the host APK as a typical Gradle project. For example, run the `gradle` command: \n\n ```text\n ./gradlew :app:assembleDebug\n ```\n\n The APK file is located in:\n\n ```carbon\n packages/apps/Car/Templates/Host/app/build/outputs/apk/debug/app-debug.apk\n ```\n\nEmbed the AOSP host\n-------------------\n\n1. Create a new `Android.mk` file to include the following content: \n\n ```carbon\n LOCAL_PATH := $(my-dir)\n ################## Start of AOSPHost target ##################\n include $(CLEAR_VARS)\n LOCAL_MODULE := CarAOSPHost\n LOCAL_LICENSE_KINDS := legacy_notice\n LOCAL_LICENSE_CONDITIONS := notice\n LOCAL_MODULE_OWNER := google\n LOCAL_SRC_FILES := AOSPHost.apk\n LOCAL_MODULE_CLASS := APPS\n LOCAL_MODULE_TAGS := optional\n LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)\n LOCAL_BUILT_MODULE_STEM := package.apk\n LOCAL_CERTIFICATE := PRESIGNED\n LOCAL_PRIVILEGED_MODULE := true\n LOCAL_PRODUCT_MODULE := true\n LOCAL_DEX_PREOPT := false\n include $(BUILD_PREBUILT)\n ```\n2. Rename the `app-debug.apk` to `AOSPHost.apk` and put the APK in the same folder as `Android.mk`.\n3. Add the `CarAOSPHost` module to your targets as `PRODUCT_PACKAGES`: \n\n ```scdoc\n PRODUCT_PACKAGES += \\\n CarAOSPHost \\\n ```\n\nAdd the permissions config\n--------------------------\n\n1. Create a file called `com.android.car.templates.host.xml` to contain the following: \n\n ```carbon\n \u003cpermissions\u003e\n \u003c!-- Rename the package to com.android.car.templates.host --\u003e\n \u003cprivapp-permissions package=\"com.android.car.templates.host\"\u003e\n \u003c!-- To be able to display activities in the cluster --\u003e\n \u003cpermission name=\"android.car.permission.CAR_DISPLAY_IN_CLUSTER\" /\u003e\n\n \u003c!-- To be able to show navigation state (turn by turn directions) in the cluster.--\u003e\n \u003cpermission name=\"android.car.permission.CAR_NAVIGATION_MANAGER\" /\u003e\n\n \u003c!-- To be considered a system-approved host --\u003e\n \u003cpermission name=\"android.car.permission.TEMPLATE_RENDERER\" /\u003e\n \u003c/privapp-permissions\u003e\n\n \u003c!-- Declare support for templated applications. --\u003e\n \u003cfeature name=\"android.software.car.templates_host\" /\u003e\n \u003c/permissions\u003e\n ```\n2. In your target, add the config file to your targets: \n\n ```makefile\n PRODUCT_COPY_FILES += \\\n \u003cthe file root\u003e/com.android.car.templates.host.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/com.android.car.templates.host.xml\n ```\n\nBuild the target\n----------------\n\nWhen you build the target, the host is installed and permission is granted:\n\n```component-pascal\n ...\n android.car.permission.CAR_NAVIGATION_MANAGER: granted=true\n android.car.permission.CAR_DISPLAY_IN_CLUSTER: granted=true\n android.car.permission.TEMPLATE_RENDERER: granted=true\n ...\n```\n| **Note:** The permission `android.car.permission.TEMPLATE_RENDERER` is *only* available after Android API level 32.\n\nTest the integration\n--------------------\n\nTo build and install the samples, see this GitHub project,\n[car-samples/car_app_library](https://github.com/android/car-samples/tree/main/car_app_library)."]]