bukwyrm
bukwyrm

Reputation: 278

Can we test Android Auto purely in emulators (2023)?

This is the same as this question from 2016 (where the answer was basically: 'No'), but Android Auto since 2019 works very differently than it did 2016, so i think it is ok to ask again:

Android Auto basically gives you the ability to project app content to a car's head unit, and work with the input the user generates there. The DHU (Desktop Head Unit) is an emulator that lets a desktop computer emulate the behavior of a real head unit (for instance translating the workings of a physical dial to keyboard shortcuts, getting fake audio input from .wav files, etc) - The material that i read always assumes that you plug a phone with your app into the computer running the DHU. I would like to have it all on one computer - is it possible to connect a virtualized phone, running the app under test on the same computer as the DHU?

Upvotes: 9

Views: 4285

Answers (2)

Bo Hellgren
Bo Hellgren

Reputation: 181

Thanks, really useful. August 2024 update: I use Pixel 4 (with Play Store) and the Tiramisu system image (API 33). I installed com.google.android.projection.gearhead_12.4.642858-release-124642858_minAPI26(x86_64)(nodpi)_apkmirror.com.apk from apkmirror. This works nicely. Almost all other combinations I have tested has different problems.

Upvotes: 0

Fernando Jascovich
Fernando Jascovich

Reputation: 459

I managed to have a purely emulator-based android-auto env. It was... somehow painful but it worked.

In order:

  • I installed desktop head unit emulator, latest available version was 2.0. sdkmanager 'extras;google;auto'
  • I created an avd using the following system image: system-images;android-33;google_apis_playstore;x86_64.
  • After launching that emulator I downloaded Android Auto apk from apkmirror. In particular, I used version 9.8 for x86_64:
  • I installed that apk using adb install PATH_TO_FILE
  • I enabled emulator's developer settings (by tapping several times on Settings -> About -> Build number)
  • I went to Auto settings which are not available from apps menu. Under your emulator settings you have to go to "Connection Preferences" and then "Android Auto".
  • Under those settings you need to enable Auto's developer mode by tapping several times on its System's version.
  • Then you'll have available the option for starting the developer head unit settings, under the three dots menu on the top right of Android Auto's settings.
  • After enabling that server you can follow the steps described on the "adb forwarding" part of the official docs about this, which are:
  • forward adb ports: adb forward tcp:5277 tcp:5277
  • Run dhu: $ANDROID_SDK_ROOT/extras/google/auto/desktop-head-unit

Plus: if you are running linux and wayland you have to run dhu using xwayland, to do that you need to set an environmental variable before the previous step:

SDL_VIDEODRIVER=x11 $ANDROID_SDK_ROOT/extras/google/auto/desktop-head-unit

Find below some print screens for helping finding things on emulator and the final victorius, glorious and spectacular dhu finally running:

Android Auto settings Auto's build version Auto's three dot settings Phone connected to DHU DHU running!!!

Upvotes: 16

Related Questions