Running Android Auto on an Emulator

The desktop-head-unit is used for testing Android Auto apps, typically in conjunction with running on a physical device and then running desktop-head-unit --usb. What if we want to test an Android Auto app without a physical device?

The Android Auto version that can be seen on Google Play emulators says that “This app isn’t compatible with your device anymore.” Some time ago, I found a StackOverflow question that is the basis for this post (though this post is updated since things have changed since then).

First, download an apk of Android Auto. I tend to try to choose a newer arm64-v8a version with screen DPI of 120-640dpi. Download the file, and then extract it:

mkdir gearhead
cd gearhead
unzip ../com.google.android.projection.gearhead_<version>.apkm

While the emulator is running, install it using:

adb install-multiple base.apk split_config.arm64_v8a.apk split_config.en.apk split_config.xxhdpi.apk

Tweak the command to add other languages or customize dpi - for example, you can add split_config.{lang}.apk to add a particular supported language.

If that succeeded, you’re mostly there. On the emulator, go to settings, connected devices, connection preferences, and then choose Android Auto. Scroll to the very bottom and click the version many times to enable developer mode for Android Auto (this is a specific setting for Android Auto, though it is mechanically the same process as the normal one for enabling debug settings in Android).

Once you’ve enabled it, tap the three dot menu in the top right, and choose “Start head unit server.”

Finally, you can start it using:

# i always run these together
adb forward tcp:5277 tcp:5277; desktop-head-unit

Every time you cold boot the emulator, you’ll need to re-start the head unit server again.