Building Android Automotive from source : <h2>TL;DR</h2>

<p>After building Android Automotive from source, how do I</p>

<ol>
<li>Run the car-emulator? </li>
<li>"Install" the CarService and related packages onto a device?</li>
</ol>

<h2>Details</h2>

<p>I'm trying to build <a href="https://source.android.com/devices/automotive/" rel="noreferrer">Android Automotive</a> from source. I'm able to successfully build it using the following commands:</p>

<p><code>
$ repo init -u https://android.googlesource.com/platform/manifest -b android-8.0.0_r11
$ source build/envsetup.sh
$ lunch car_emu_x86_64-userdebug
$ make -j8 V=1 &amp;&gt;&gt; make.log
</code></p>

<p>My question is how do I run the emulator? After googling and going through some stackoverflow posts, I came across this:</p>

<p>First, I set an env variable in the command-line (The emulator uses this to determine which emulator to launch)</p>

<p><code>export ANDROID_PRODUCT_OUT=/path/to/build_root</code></p>

<p>Next, I created a file <code>car-emulator.sh</code> and put this in it (the build was done on an Ubuntu machine)</p>

<pre><code>#!/usr/bin/env bash

ANDROID_BUILD_OUT=/path/to/build_root/out
PREBUILT=/path/to/build_root/prebuilts
EMULATOR_OUT=${ANDROID_BUILD_OUT}/target/product/car-x86_64

${PREBUILT}/android-emulator/linux-x86_64/emulator \
    -sysdir ${EMULATOR_OUT} \
    -system ${EMULATOR_OUT}/system.img \
    -ramdisk ${EMULATOR_OUT}/ramdisk.img \
    -data ${EMULATOR_OUT}/userdata.img \
    -kernel ${PREBUILT}/qemu-kernel/x86_64/kernel-qemu \
    -scale 0.7 \
    -memory 512 \
    -partition-size 1024
</code></pre>

<p>I also tried to download the relevant (darwin-x86_64) files from the build machine to my Mac laptop and tried running there. The emulator starts but crashes immediately with a huge native stack trace.</p>

<p>The next part of my question is how do I install this image on a device?
I see that the CarService.apk has been generated. Is it sufficient to install this APK on a device for it to work? Or should the CarService and related packages be part of a system image that needs to be flashed in its entirety?</p>
