Add support for Android Automotive OS to your app

Stay organized with collections Save and categorize content based on your preferences.

Android Automotive OS allows users to install apps in the car. In order to reach users on this platform, you need to distribute a driver-optimized app that is compatible with Android Automotive OS. You can re-use almost all of the code and resources in your Android Auto app, but you must create a separate build that meets the requirements on this page.

Development overview

Adding Android Automotive OS support is simple and only requires a few steps:

  1. Create an automotive module
  2. Declare support for Android Automotive OS
  3. Declare your CarAppService and CarAppActivity
  4. Update your gradle dependencies

Use Android Studio Bumblebee or newer to ensure that all Automotive OS features are enabled.

Create an automotive module

Some components of Android Automotive OS, such as the manifest, have platform-specific requirements, so you need to create a module that can keep the code for these components separate from other code in your project, such as the code used for your phone app.

For an existing project, follow these steps to add an automotive module to your project:

  1. In Android Studio, select File > New > New Module.
  2. Select Automotive Module, then click Next.
  3. Provide an Application/Library name. This is the name that users see for your app on Android Automotive OS.
  4. Provide a Module name.
  5. Adjust the Package name to match your existing app.
  6. Select API 29: Android 10 (Q) for the Minimum SDK, and then click Next.
  7. Select Add No Activity, and click Finish.

If you are starting a new project:

  1. In Android Studio, select File > New > New Project.
  2. Select Automotive for Project Type.
  3. Select No Activity, then click Next.
  4. Provide a Name for your project. This is the name that users see for your app on Android Automotive OS.
  5. Provide a Package name. See the Package names section for more details on selecting a package name.
  6. Select API 29: Android 10 (Q) for the Minimum SDK, then click Next.

    All cars that support the Car App Library on Android Automotive OS run on Android 10 (API level 29) or higher, so selecting this value targets 100% of compatible cars.

After creating your module in Android Studio, open the AndroidManifest.xml in your new automotive module:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.car.app">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" />

    <uses-feature
        android:name="android.hardware.type.automotive"
        android:required="true" />

</manifest>

You'll notice some standard app information in the application element, but there's also a uses-feature element that declares support for Android Automotive OS. Also note that there are no activities declared in the manifest.

Next, add the following uses-features elements to your manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.car.app">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" />

    <uses-feature
        android:name="android.hardware.type.automotive"
        android:required="true" />
    <uses-feature
        android:name="android.software.car.templates_host"
        android:required="true" />

    <uses-feature
        android:name="android.hardware.wifi"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.screen.portrait"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.screen.landscape"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />

</manifest>

The first uses-feature element declares that your app uses the Templates Host to run. Explicitly setting the remaining four uses-feature elements to not required ensures that your app doesn't conflict with available hardware features in Android Automotive OS devices.

Declare support for Android Automotive OS

Use the following manifest entry to declare that your app supports Android Automotive OS:

<application>
    ...
    <meta-data android:name="com.android.automotive"
        android:resource="@xml/automotive_app_desc"/>
    ...
</application>

This manifest entry refers to an XML file that declares what automotive capabilities your app supports. To indicate that you have a Car App Library app, add an XML file named automotive_app_desc.xml to the res/xml/ directory in your Android Automotive OS module. This file should include the following content:

<automotiveApp>
    <uses name="template"/>
</automotiveApp>

Declare your CarAppService and CarAppActivity

Android Automotive OS uses your CarAppService implementation and CarAppActivity declaration to launch your app. Refer to Create your CarAppService and Session and Declare your CarAppService for instructions on implementing and declaring your CarAppService.

On Android Automotive OS, your Screens are rendered on an Activity that is included in the Car App Library, but you must declare it in your Manifest with the following activity element:

<activity
    android:exported="true"
    android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
    android:name="androidx.car.app.activity.CarAppActivity"
    android:launchMode="singleTask"
    android:label="Your app name">

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <!-- Additionally include the category below ONLY for navigation apps -->
        <category android:name="android.intent.category.APP_MAPS" />
    </intent-filter>

    <!-- Additionally include the intent-filter below ONLY for navigation apps -->
    <intent-filter>
        <action android:name="androidx.car.app.action.NAVIGATE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="geo" />
    </intent-filter>

    <meta-data android:name="distractionOptimized" android:value="true" />

</activity>

Update your gradle dependencies

We recommend that you keep your CarAppService in a separate module that you share between your phone app and your automotive module. If you're using this approach, you need to update your automotive module to include the shared module, as shown in the following snippet:

my-automotive-os-module/build.gradle

Groovy

buildscript {
    ...
    dependencies {
        ...
        implementation project(':shared_module_name')
    }
}

Kotlin

buildscript {
    ...
    dependencies {
        ...
        implementation(project(":shared_module_name"))
    }
}

Other Considerations

Keep these other considerations in mind when developing your Android Automotive OS app:

Package names

Because you distribute a separate APK for Android Automotive OS, you have the option to reuse the package name from your mobile app or create a new package name. The main difference is that with a different package name your app has two completely separate Play Store listings, whereas if you reuse your current package name then you'll have a single listing across both platforms.

This is predominantly a business decision. For example, if you have one team working on the mobile app and a completely separate team working on your Android Automotive OS app, then it might make sense to have separate package names and let each team manage their own Play Store listing. There is not a large difference in the technical effort required to use either approach.

The following table summarizes some of the other key differences between each approach:

Feature Same package name New package name
Store listing Single Multiple
Mirrored install Yes. “Fast app reinstall” during the setup wizard No
Play Store Review process Blocking reviews. Currently, if the review fails for one APK, other APKs submitted in the same release are blocked Individual reviews
Statistics, metrics, and vitals Combined. Note: You can filter by device name for automotive-specific data (for example, 2 cars in year 2020) Separate
Indexing and search ranking Build off of current standing Does not carry over
Integrating with other apps Most likely no changes needed, assuming media code is shared between both APKs Might have to update the corresponding app (for example, for URI playback with Google Assistant)

Offline content

If applicable, implement offline support in your app. Cars with Android Automotive OS are expected to have their own data connectivity, that is to say either a data plan included in the cost of the vehicle or paid for by the user. However, cars are also expected to have more variable connectivity than mobile devices. As such, we recommend thinking about the best offline support strategy for your content. The disk space on cars may vary, so ensure that users have a way to delete offline content.

Here are a few things to keep in mind as you consider your offline support strategy:

  • The best time to download content is when your app is currently in use.
  • Do not assume that WiFi is available. A car might never come into WiFi range or the OEM might have disabled WiFi in favor of a cellular network.
  • While it is okay to smartly cache the content that you think users are likely to use, we highly recommend allowing the user to change this behavior.

Frequently asked questions

See the following sections for answers to some frequently asked questions about Android Automotive OS.

Are there any restrictions or recommendations for using third-party SDKs and libraries?

We don’t have any specific guidelines on using third-party SDKs and libraries. If you choose to use third-party SDKs and libraries, you are still responsible for complying with all the car app quality requirements.

How do I publish my Android Automotive OS app using the Google Play Console?

The app publishing process is similar to publishing your phone app, but you use a different release type. To opt in your app to use the Android Automotive OS release type, follow these steps:

  1. Open the Play Console.
  2. Select your app.
  3. From the left menu, select Release > Setup > Advanced settings > Release types.
  4. Select Add release type > Android Automotive OS, then follow the instructions in the Play Console.

Troubleshooting

See the following sections for help with some common troubleshooting scenarios on Android Automotive OS.

Even after uninstalling a Car App Library app from the system settings, I get an error when trying to install a new version.

To be sure that the app is uninstalled, use the command adb uninstall app.package.name.