July 13, 2024

Pyp Vaporisimo

more advanced technology

How to Build Your First App for Android Automotive OS – Grape Up

3 min read
How to Build Your First App for Android Automotive OS – Grape Up

Android Automotive OS is getting more recognition as automotive companies are looking to provide their customers with a more tailored experience. Here we share our guide to building the first app for AAOS.

Before you start, read our first article about AAOS and get to know our review to be aware of what to expect. Let’s try making a simple Hello World app for android automotive. To get an IDE, go to Android Studio Preview | Android Developers and get a canary build:

AAOS Hello World: How to Build Your First App for Android Automotive OS

In the next step, prepare SDK, check and download the Automotive system image in SDK manager. You can get any from api32, Android 9, or Android 10, but I do not recommend the newest one as it is very laggy and crashes a lot right now. There are also Volvo and Polestar images.

For those you need to add links to SDK Update Sites:



Start a new project, go to File> New Project and choose automotive with no activity

Android Automotive OS

A nice and clean project should be created, without any classes: Go to build.gradle and add the car app library into dependencies, refresh the project to make it get

AAOS Hello World

our new dependency:

implementation "androidx.car.app:app-automotive:1.2.0-rc01"

Let’s write some code, first our screen class. Name it as you want and make it extend Screen class from android.car.app package and make it implement required methods:

public class GrapeAppScreen extends Screen 

   public GrapeAppScreen(@NonNull CarContext carContext) 

   public Template onGetTemplate() 
       Row row = new Row.Builder()
.setTitle("Thats our Grape App!").build();

       return new PaneTemplate.Builder(
               new Pane.Builder()

That should create a simple screen with our icon and title, now create another class extending CarAppService from the same package and as well make it implement the required methods. From createHostValidator() method return a static one that allows all hostnames for the purpose of this tutorial and return brand new session with our screen in onCreateSession(), pass CarContext using Session class getCarContext() method:

public class GrapeAppService extends CarAppService 

   public GrapeAppService() 

   public HostValidator createHostValidator() 
       return HostValidator.ALLOW_ALL_HOSTS_VALIDATOR;

public Session onCreateSession() 
   return new Session() 
       public Screen onCreateScreen(@Nullable Intent intent) 
           return new GrapeAppScreen(getCarContext());

Next, move to AndroidManifest and add various features inside the main manifest tag:

   android:required="true" />
   android:required="true" />
   android:required="false" />
   android:required="false" />
   android:required="false" />

Inside the Application tag add our service and activity, don’t forget minCarApiLevel as lack of this will throw an exception on app start:


<meta-data android:name="androidx.car.app.minCarApiLevel"

           <action android:name="androidx.car.app.CarAppService" />

       android:label="GrapeApp Starter"

           <action android:name="android.intent.action.MAIN" />
           <category android:name="android.intent.category.LAUNCHER" />
           android:value="true" />

Now we can upload our application to the device, verify that you have an automotive emulator created, use automotive configuration, and hit run. The app is run in Google Automotive App Host, so if it is your first application on this device, it may require you to get to the play store and get it.

That’s how it looks:

Build Your First App for Android Automotive OS

The last thing, we’ll add a navigation button that will pop a Toast. Modify onGetTemplate() in Screen class, add Action and ActionStrip:

Action action = new Action.Builder()
               () -> CarToast.makeText(getCarContext(), "Hello!", CarToast.LENGTH_SHORT).show())
       .setTitle("Say hi!")

ActionStrip actionStrip = new 

Add it to PaneTemplate:

return new PaneTemplate.Builder(
       new Pane.Builder()
)       .setActionStrip(actionStrip)

That’s our HelloWorld app:

Now you have the HelloWorld example app up and running using Car App Library. It takes care of displaying and arranging everything on the screen for us. The only responsibility is to add screens and actions we would like to have(and a bit of configuration). Check the Car app library to explore more of what can be done with it, play around with creating your app, and definitely check our blog soon for more AAOS app creation content.

Android Automotive OS

Leave a Reply

pypvaporisimo.com | Newsphere by AF themes.