Build video apps for Android Automotive OS

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

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

Test your existing app on an Android Automotive OS emulator

To begin building your app for Android Automotive OS, first test your existing mobile app 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 the instructions in Run your app on the emulator.

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

  • Infotainment screens have fixed orientations. To meet the car app quality guidelines, apps must support both portrait and landscape orientations.
  • APIs available on other devices might not be available on Android Automotive OS. For example, some Google Play Services APIs are not available on Android Automotive OS. See the Disable features section for details on how to handle these issues.

Configure your app's manifest files

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

Required Android Automotive OS features

To be listed 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 <uses-feature> elements shown in the previous code sample, because they can't depend on car-specific hardware. So, to ship the same app for both automotive and non-automotive devices, you need to generate at least two flavors of your app: one for automotive devices and another for mobile devices. 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 must have different version codes since they are uploaded to the Play Store tracks separately.

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

In addition to the elements shown in the previous code sample, 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 helps ensure 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 your automotive app supports video, add an XML file named automotive_app_desc.xml to the res/xml/ directory in your project. In this file, 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"/>

Don't include distraction-optimized activities

Video apps are meant for use only while parked. As such, do not include the following <meta-data> element in any <activity> element:

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

Without this metadata, your app's activities are blocked automatically by the OS when the car enters driving mode, to reduce distractions for the driver. This happens as an onPause lifecycle callback, during which you must pause both video and audio playback from your app.

Optimize your app for Android Automotive OS

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

Disable features

If you are making an existing mobile app available on Android Automotive OS, certain features and functionality might not be relevant or available. For example, cars generally don't 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 whether the app is running on Android Automotive OS by checking for the FEATURE_AUTOMOTIVE feature, as shown in the following example:

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, you can use the CarConnection API from the Android for Cars App Library to detect whether the app is running on Android Automotive OS or Android Auto—or if it is not connected to a car at all.

For Picture-in-Picture (PiP), follow the established best practices to check whether the feature is available and react appropriately.

Handle offline scenarios

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

  • Users might opt out of cellular data offered as part of a subscription package from the auto maker.
  • Access to cellular data might be limited in certain areas.
  • Cars with Wi-Fi radios might be out of Wi-Fi range, or an OEM might disable Wi-Fi in favor of a cellular network.

Be prepared to handle these scenarios in your app by gracefully degrading functionality that depends on internet access, such as by offering offline content. For more information, see the best practices for optimizing networking.

Use alternate resources

To help adapt your app for cars, you can use the car resource qualifier to provide alternate resources when running on an Android Automotive OS vehicle. For example, if you use Dimension resources to store padding values, you could use a larger value for the car resource set to make touch targets larger.

Test Video Apps on Android Automotive OS

In general, follow the instructions available at Test Android apps for cars. Only the SDK 30 and 32 emulators available through Android Studio include the android-automotive-video library, so use them for testing the Automotive OS build of your app. Lower SDK emulators don't have the library, so adb installations of apps that require it will fail. The library might be included on production vehicles at lower OS levels.

Frequently asked questions

Is Widevine DRM supported?

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