1Android for Cars App Library Samples
2===========================================
3This directory contains sample apps that use Android for Cars App Library.
4Please find the library documentation at https://developer.android.com/training/cars/navigation.
5
6Prerequisites
7--------------
8- [Android 6.0 SDK (API level 23)](https://developer.android.com/studio/releases/platforms#6.0) or newer.
9
10Build and Run From Android Studio
11-----------------------
12In order to build app APKs,
13
141. Open the project in Android Studio: File -> Open -> Select this directory and click OK.
15
162. Select a sample app directory (e.g. `showcase`) in the `Project Structure` UI on the top left. Each sample app has two build targets, `showcase/mobile` is for the `projected` platform and `showcase/automotive` is for the `embedded` platform.
17
183. Go to `Build -> Make Module 'androidx.car.app.app-samples.<sample_app>.<platform>'`. The apks
19 will be generated in `<sample_app>/<platform>/build/outputs/apk`.
20
21In order to install and run the apps,
22
231. Open the AndroidX project in Android Studio.
24
252. Go to `Run -> Edit Configurations`, select a sample app target (e.g. `car.app.app-samples
26.showcase-mobile`). If you are building for the `mobile` platform, also select `Launch: Nothing
27` in `General -> Launch Options`. Click `OK` to close the dialog.
28
293. Select `Run -> Run <sample_app>`, to run the app, which will just install it in the selected
30 device.
31
32Run From the Command Line
33---------------------
341. Open the project in Android Studio to download the gradle wrapper files.
35
362. Run `./gradlew :<sample_app>:<platform>:assemble` to assemble the APKs. E.g.
37
38```bash
39./gradlew :showcase:mobile:assemble
40./gradlew :showcase:automotive:assemble
41```
42
43The APK should be generated under the sample app’s build directory, e.g. `<sample_app>/<platform>/build/outputs/apk/debug`.
44
45If you see this error during the build:
46
47    ```shell
48    > SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by
49     setting the sdk.dir path in your projects local properties file at <project_path
50     >/local.properties
51    ```
52
53Create `local.properties` file under the project directory, and copy the following line:
54
55    ```
56    sdk.dir = <your android sdk directory path>
57    ```
58
593. Install the APK with ADB:
60
61```bash
62adb install <path_to_sample_app_apk>
63```
64
65Run the Mobile Apps in the Desktop Head Unit (DHU)
66-------------------------------------------
67Follow the instructions in [Test Android apps for cars][1] to run the sample apps in the DHU.
68
69In short, do the following:
70
711. [Enable the Android Developer Settings][2]
722. [Enable Unknown Sources in Android Auto][3]
733. [Run the DHU][4]
74
75**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.
76
77Run the Automotive Apps in the Automotive OS Emulator
78-------------------------------------------
79In order to use the Automotive OS emulator, download the Android Studio 4.2 or higher (currently
80only available in the Beta and Canary tracks), and do the following:
81
821. Follow instructions to [run an Automotive OS emulator][5].
832. Follow instructions to [update the Template Host app][6].
84
85[1]: https://developer.android.com/training/cars/testing
86[2]: https://developer.android.com/studio/debug/dev-options
87[3]: https://developer.android.com/training/cars/testing#step1
88[4]: https://developer.android.com/training/cars/testing#running-dhu
89[5]: https://developer.android.com/training/cars/testing#system-images
90[6]: https://developer.android.com/training/cars/apps/automotive-os
91