October 6, 2022


Software Development

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


Android Automotive OS is acquiring a lot more recognition as automotive firms are searching to give their prospects with a a lot more tailor-made working experience. Right here we share our manual to constructing the initially application for AAOS.

In advance of you get started, read our first write-up about AAOS and get to know our critique to be knowledgeable of what to assume. Let’s consider producing a uncomplicated Hello there Earth application for android automotive. To get an IDE, go to Android Studio Preview | Android Builders and get a canary develop:

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

In the future action, prepare SDK, test and down load the Automotive system image in SDK supervisor. You can get any from api32, Android 9, or Android 10, but I do not advocate the latest a single as it is pretty laggy and crashes a great deal ideal now. There are also Volvo and Polestar photos.

For all those you need to have to incorporate one-way links to SDK Update Internet sites:



Commence a new project, go to File> New Task and pick out automotive with no activity

Android Automotive OS

A great and clear task should really be developed, with out any classes: Go to establish.gradle and incorporate the auto application library into dependencies, refresh the challenge to make it get

AAOS Hello World

our new dependency:

implementation "androidx.motor vehicle.application:app-automotive:1.2.-rc01"

Let’s compose some code, to start with our screen course. Title it as you want and make it extend Display course from android.motor vehicle.application offer and make it apply essential methods:

general public course GrapeAppScreen extends Display 

   community GrapeAppScreen(@NonNull CarContext carContext) 

   general public Template onGetTemplate() 
       Row row = new Row.Builder()
.setTitle("Thats our Grape Application!").establish()

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

That should really develop a straightforward display with our icon and title, now make one more course extending CarAppService from the same deal and as properly make it carry out the needed methods. From createHostValidator() strategy return a static a person that allows all hostnames for the objective of this tutorial and return model new session with our display in onCreateSession(), pass CarContext utilizing Session class getCarContext() method:

public class GrapeAppService extends CarAppService 

   community GrapeAppService() 

   community HostValidator createHostValidator() 
       return HostValidator.Allow_ALL_HOSTS_VALIDATOR

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

Next, move to AndroidManifest and include many capabilities inside of the most important manifest tag:

Inside the Software tag include our support and action, really do not fail to remember minCarApiLevel as absence of this will throw an exception on app start off:




Now we can add our software to the product, validate that you have an automotive emulator designed, use automotive configuration, and strike run. The application is run in Google Automotive App Host, so if it is your to start with application on this product, it may well involve you to get to the engage in keep and get it.

That’s how it appears:

Build Your First App for Android Automotive OS

The last factor, we’ll add a navigation button that will pop a Toast. Modify onGetTemplate() in Display screen class, increase Motion and ActionStrip:

Action motion = new Action.Builder()
               () -> CarToast.makeText(getCarContext(), "Hello!", CarToast.Duration_Shorter).demonstrate())
       .setTitle("Say hello!")

ActionStrip actionStrip = new 

Include it to PaneTemplate:

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

That’s our HelloWorld application:

Now you have the HelloWorld example app up and functioning using Car or truck Application Library. It can take treatment of exhibiting and arranging everything on the monitor for us. The only accountability is to increase screens and steps we would like to have(and a little bit of configuration). Verify the Vehicle application library to investigate far more of what can be performed with it, enjoy all around with creating your app, and certainly examine our blog soon for far more AAOS app development articles.

Android Automotive OS


Source backlink