Android Car Samples

repository·main·Indexed 19 days ago

https://github.com/android/car-samples

A collection of Android Studio projects providing practical examples for developing automotive applications. It includes samples for the Car App Library, compatible with Android Auto and Android Automotive OS (AAOS), as well as specialized AAOS samples like the Car Gear Viewer. The repository demonstrates the use of various UI templates, such as SectionedItemTemplate and MapWithContentTemplate, and provides guidance on building and running apps via Android Studio, the command line, the Desktop Head Unit (DHU), and the Automotive OS emulator.

Tokens
7.2K
Snippets
18
Records
30
Agent score
65%

What's inside android-car-samples

  1. Overview of Car Samples Repository

    main
    This repository provides a collection of individual Android Studio projects designed to help developers build applications for automotive environments. The samples are organized based on the specific integration libraries they utilize.
  2. Overview of the Showcase Sample

    main
    The Showcase Sample is a demonstration application designed to showcase the various templates and features available within the Car App Library. Developers can use this sample to understand how to implement different UI templates and utilize the library's core capabilities in a real-world app context.
  3. Overview of Android Automotive OS (AAOS) samples

    main

    This repository contains sample applications and libraries specifically designed for Android Automotive OS (AAOS), the Android-based infotainment system built into vehicles.

    Important Note: The samples in this library are specialized for the automotive environment and currently only run on AAOS-compatible hardware or emulators.

  4. Overview of AAOS Car Gear Viewer (Kotlin)

    main

    The AAOS Car Gear Viewer (Kotlin) sample demonstrates how to connect to the Android Automotive OS (AAOS) Car API to monitor and display vehicle gear changes on an In-Vehicle Infotainment (IVI) screen.

    Key technical details:

    • It uses CarPropertyManager to subscribe to gear change events.
    • It updates the UI upon receiving valid change events.
    • It logs error events received from the Car API.
    • It requires Android P (API 28) or higher, though the sample specifically targets API 29+ for its SDK requirements.
  5. Understand the Car App Library integration

    main

    The Car App Library is used to build specialized automotive applications such as navigation, parking, and charging apps. These applications are compatible with:

    • Android Auto: Apps running on a phone connected to a car.
    • Android Automotive OS: Apps running directly on the car's head unit.
  6. Run Mobile Apps in the Desktop Head Unit (DHU)

    main

    To test mobile (projected) apps on your computer, use the Desktop Head Unit (DHU).

    Steps:

    1. Enable Android Developer Settings on your device.
    2. Enable Unknown Sources in Android Auto.
    3. Run the DHU.

    Note for Android Q users: If you cannot find the Android Auto app in the launcher, navigate to Settings -> Apps & Notifications -> See all apps -> Android Auto -> Advanced -> Additional settings in the app.

  7. Build and Install Samples via Command Line

    main

    You can assemble and install sample APKs using the Gradle wrapper and ADB.

    1. Assemble APKs

    First, open the project in Android Studio once to ensure the Gradle wrapper files are downloaded. Then run:

    ./gradlew :<sample_app>:<platform>:assemble

    Examples:

    • Mobile: ./gradlew :showcase:mobile:assemble
    • Automotive: ./gradlew :showcase:automotive:assemble

    Generated APKs are located in: <sample_app>/<platform>/build/outputs/apk/debug.

    2. Troubleshooting SDK Location

    If you encounter an SDK location not found error, create a local.properties file in the project root and add your SDK path:

    sdk.dir = <your android sdk directory path>

    3. Install via ADB

    Once the APK is built, install it using:

    adb install <path_to_sample_app_apk>
    # Example: Assemble showcase mobile app
    ./gradlew :showcase:mobile:assemble
    
    # Example: Install the resulting APK
    adb install showcase/mobile/build/outputs/apk/debug/app-debug.apk