tree: e58e758dbe89cf799f72f6d294e99cfdaa54e257 [path history] [tgz]
  1. navigation/
  2. showcase/
  3. github_build.gradle
  4. github_gradle.properties
  5. github_README.md
  6. github_settings.gradle
  7. README.md
car/app/app-samples/README.md

Android for Cars App Library Samples

This directory contains sample apps that use Android for Cars App Library. Please find the library documentation at https://developer.android.com/training/cars/navigation.

Build and Run From Android Studio

In order to build app APKs,

  1. Open the AndroidX project in Android Studio.

  2. Select a sample app directory (e.g. showcase-mobile) in the Project Structure UI on the top left. Each sample app has two build targets, one for the mobile platform and the other for the automotive platform.

  3. Go to Build -> Make Module 'androidx.car.app.app-samples.<sample_app>-<platform>'. The apks will be generated in <repo root>/out/androidx/car/app/app-samples/<sample_app>-<platform>/build /outputs/apk.

In order to install and run the apps,

  1. Open the AndroidX project in Android Studio.

  2. Go to Run -> Edit Configurations, select a sample app target (e.g. car.app.app-samples .showcase-mobile). If you are building for the mobile platform, also select Launch: Nothing in General -> Launch Options. Click OK to close the dialog.

  3. Select Run -> Run <sample_app>, to run the app, which will just install it in the selected device.

Run From the Command Line

Run ./gradlew :car:app:app-samples:<sample_app>-<platform>:assemble to assemble the APKs. E.g.

./gradlew :car:app:app-samples:showcase-mobile:assemble
 ./gradlew :car:app:app-samples:showcase-automotive:assemble

The APKs will be generated in <repo root>/out/androidx/car/app/app-samples/<sample_app>-<platform>/build/outputs/apk.

Install the APK with ADB:

adb install <path_to_sample_app_apk>

In order to install to a device directly, run the installDebug or installRelease gradle task . E.g.

./gradlew :car:app:app-samples:showcase-mobile:installDebug
./gradlew :car:app:app-samples:showcase-automotive:installRelease

Run the Mobile App in the Desktop Head Unit (DHU)

Follow the instructions in Test Android apps for cars to run the sample apps in the DHU.

In short:

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

Note: In Android Q, there is no Android Auto app in the launcher. The way to get to the settings in that case is through Settings -> Apps & Notifications -> See all apps -> Android Auto -> Advanced -> Additional settings in the app.

Run the Automotive Apps in the Automotive OS Emulator

In order to use the Automotive OS emulator, download the Android Studio 4.2 or higher (currently only available in the Beta and Canary tracks), and do the following:

  1. Follow instructions to run an Automotive OS emulator.
  2. Follow instructions to update the Template Host app.