Build video apps for Android Automotive OS

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

Android Automotive OS allows users to run your video app on a car's infotainment system while the car is parked.

Test the app on an Android Automotive OS emulator

To begin building your app for Android Automotive OS, the first thing you should do is test your existing mobile app (for phones and tablets) on an Android Automotive OS emulator. To set up an emulator, follow the steps in Test Android apps for cars. You can then run the app by following these instructions.

When running your app, you should watch out for compatibility issues such as the following:

  • Infotainment screens come in fixed orientations. Per the car app quality guidelines, apps should support both portrait and landscape orientations.
  • APIs available on other devices may not be available on Android Automotive OS. For example, some Google Play Services APIs are not available on Android Automotive OS. See Disable features for more details on how to handle these issues.

Configure your app's manifest files

To target Android Automotive OS, there are a number of manifest entries your app must have. With them, apps targeting Android Automotive OS can be submitted to the Play Store using a separate Automotive release type, and will be put through a manual review process to ensure they're safe for use in a car. See Distribute Android apps for cars for more details.

Require Android Automotive OS features

To show up in the Play Store in a car, video apps built for Android Automotive OS must include the following <uses-feature> and <uses-library> elements in the AndroidManifest.xml file.

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

Apps submitted to non-automotive tracks can't declare the above <uses-feature> element as they can't depend on car-specfific hardware. As such, to ship the same app on both automotive and non-automotive devices, apps should generate at least two flavors of the app, one for automotive devices and another for mobile devices (phones and tablets). For more information on how to create these separate flavors, refer to the following documentation:

The two flavors of the app can share the same package name, but should have different version codes since they will be uploaded to the Play Store tracks separately.

Alternatively, instead of using separate flavors, apps can use separate package names for mobile and automotive APKs or App Bundles. To understand the trade-offs of each approach, please refer to Package names in the media app developer guide.

In addition to the previously-mentioned elements, apps built for Android Automotive OS must include the following <uses-feature> elements in the root <manifest> element.

<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"/>

Explicitly setting these features to not required ensures that your app doesn't conflict with available hardware features in Android Automotive OS devices.

Mark your app as a video app

To indicate that you have an automotive app that supports video, add an XML file named automotive_app_desc.xml to the res/xml/ directory in your project. This file should include the following content:

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

Then, within the <application> element of your manifest, add the following <meta-data> element referencing the XML file:

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

Ensure there are no distraction optimized activities

Video apps are currently meant for use only while parked. As such, no <activity> element should include the following <meta-data> element:

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

Without this metadata, your app's activities will be blocked automatically by the OS when the car enters driving mode to reduce distractions for the driver. To your app, this will happen as an onPause lifecycle callback, during which you should ensure both video and audio playback from your app is paused.

Optimize your app for Android Automotive OS

To give your users the best experience possible, you may need to enable or disable certain functionality depending on if your app is running on a car or not.

Disable features

If an existing mobile app is being made available on Android Automotive OS, certain features and functionality may not be relevant or available. For example, cars generally do not provide access to cameras. Additionally, only a subset of Google Play services are available on Android Automotive OS - see Google Play services for cars for more details.

You can use the PackageManager.hasSystemFeature API to detect if the app is running on Android Automotive OS by checking for the FEATURE_AUTOMOTIVE feature.

Kotlin

val packageManager: PackageManager = ... // Get a PackageManager from a Context
val isCar = packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)
if (isCar) {
  // Enable or disable a given feature
}

Java

PackageManager packageManager = ... // Get a PackageManager from a Context
boolean isCar = packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)
if (isCar) {
  // Enable or disable a given feature
}

Alternatively, if your app also has an Android Auto component, it may make sense to use the CarConnection API from the Car App Library to detect if the app is running on Android Automotive OS, Android Auto, or if it is not connected to a car at all.

For Picture-in-Picture (PiP), you can follow the established best practices to check if the feature is available or not and react appropriately.

Handle offline scenarios

While cars are becoming increasingly internet connected, apps should be able to handle running without an internet connection, such as in the following cases:

  • Auto makers may offer cellular data as part of a subscription package (which users may or may not purchase).
  • Users may have cellular data enabled, but access may be limited in certain areas (just like with a phone).
  • Cars may or may not have WiFi radios. In those that do, a car may never come into WiFi range or an OEM may have disabled WiFi in favor of a cellular network.

Apps should be prepared to handle these scenarios and gracefully degrade (for example, by offering offline content). For more information, see the best practices for optimizing networking.

Testing Video Apps on Android Automotive OS

In general, developers can follow the instructions available at Test Android apps for cars. Currently only the SDK 32 emulator available through Android Studio includes the android-automotive-video library so it should be used for testing. Lower SDK emulators will not allow adb installations of apps with the video library required, though it may be included for production vehicles at those OS levels.

Frequently asked questions

Is Widevine DRM supported?

Yes, Widevine DRM L3 is supported on Android Automotive OS.