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.
In order to build app APKs,
Open the AndroidX project in Android Studio.
Select a sample app directory (e.g. helloworld-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.
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,
Open the AndroidX project in Android Studio.
Go to Run -> Edit Configurations
, select a sample app target (e.g. car.app.app-samples .helloworld-mobile
). If you are building for the mobile
platform, also select Launch: Nothing
in General -> Launch Options
. Click OK
to close the dialog.
Select Run -> Run <sample_app>
, to run the app, which will just install it in the selected device.
Run ./gradlew :car:app:app-samples:<sample_app>-<platform>:assemble
to assemble the APKs. E.g.
./gradlew :car:app:app-samples:helloworld-mobile:assemble ./gradlew :car:app:app-samples:helloworld-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:helloworld-mobile:installDebug ./gradlew :car:app:app-samples:helloworld-automotive:installRelease
Follow the instructions in Test Android apps for cars to run the sample apps in the DHU.
In short:
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.
Important: The host component required to support car apps in the Automotive OS emulator has not yet been released, and hence these samples will not work in the Automotive OS emulator.