Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building Android Automotive from source

TL;DR

After building Android Automotive from source, how do I

  1. Run the car-emulator?
  2. "Install" the CarService and related packages onto a device?

Details

I'm trying to build Android Automotive from source. I'm able to successfully build it using the following commands:

$ 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 &>> make.log

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

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

export ANDROID_PRODUCT_OUT=/path/to/build_root

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

#!/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

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.

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?

like image 455
curioustechizen Avatar asked Sep 26 '17 09:09

curioustechizen


People also ask

Is Android Automotive Open Source?

Android Automotive is an operating system and platform running directly on the in-vehicle hardware. It is a full-stack, open source, highly customizable platform powering the infotainment experience. Android Automotive supports apps built for Android as well as those built for Android Auto.

How do I make my Android Auto car?

Plug a USB cable into your vehicle's USB port and plug the other end of the cable into your Android phone. Your phone might ask you to download the Android Auto app or update to the newest version of the app. Follow the on-screen instructions to complete setup.

Can I make my car compatible with Android Auto?

To use Android Auto on your car display, your car needs to be compatible with Android Auto or have an aftermarket unit installed. Android Auto won't work on all cars equipped with a USB port. See this list of manufacturers to check if your car is compatible. Not all USB cables will work with all cars.

Can Android Auto be retrofitted?

However, if your car has a more integrated system, modern installers have worked out ways to retrofit a system that can run Android Auto and make it look factory.


2 Answers

This is how I got it to work on Android 8.1.0 branch OPM5.171019.017:

$ source ./build/envsetup.sh
$ lunch aosp_car_x86_64-eng
$ emulator

Followed by the below output on the terminal:

emulator: WARNING: system partition size adjusted to match image file (2562 MB > 200 MB)

emulator: WARNING: data partition size adjusted to match image file (550 MB > 200 MB)

warning: host doesn't support requested feature: CPUID.80000001H:ECX.sse4a [bit 6]

warning: host doesn't support requested feature: CPUID.80000001H:ECX.sse4a [bit 6]

And the android emulator display shows up booting android automotive. I would recommend you try building the engineering version if the above solution does not work in userdebug mode. Please share the stack trace for further analysis.

About the second part of your question. I think you are mixing up android auto with android automotive.

Android Auto is just an app and can be deployed/setup using an APK and some minor tweaking, while Android Automotive is a customized version of android designed specifically for the automotive industry with its own set of system applications. Therefore, it cannot be simply deployed on a device by just installing an APK.

like image 188
4aRk Kn1gh7 Avatar answered Nov 14 '22 14:11

4aRk Kn1gh7


This is my PC env that can run Android Car Emulator Ubuntu 16, 16G Ram, 1T Disk

$ repo init -u https://android.googlesource.com/platform/manifest -b android-9.0.0_r39
$ source build/envsetup.sh
$ lunch car_emu_x86_64-userdebug
$ make -j8
$ emulator 

and then Android Emulator boot up just as below.

Android Emulator

like image 2
jin Avatar answered Nov 14 '22 14:11

jin