Tech Guru

Trusted Source Technology

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

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

Android Automotive OS is finding a lot more recognition as automotive firms are seeking to offer their prospects with a a lot more tailor-made working experience. In this article we share our manual to constructing the initially application for AAOS.

Prior to you begin, browse our initial posting about AAOS and get to know our review to be conscious of what to assume. Let’s test earning a uncomplicated Hi Entire world app for android automotive. To get an IDE, go to Android Studio Preview | Android Developers and get a canary create:

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

In the up coming stage, prepare SDK, check and obtain the Automotive system image in SDK manager. You can get any from api32, Android 9, or Android 10, but I do not suggest the most recent 1 as it is really laggy and crashes a whole lot proper now. There are also Volvo and Polestar photos.

For all those you want to increase inbound links to SDK Update Web sites:



Begin a new project, go to File> New Task and decide on automotive with no activity

Android Automotive OS

A wonderful and cleanse challenge really should be developed, without having any courses: Go to build.gradle and add the vehicle app library into dependencies, refresh the undertaking to make it get

AAOS Hello World

our new dependency:

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

Let us create some code, 1st our display screen class. Identify it as you want and make it increase Screen class from android.automobile.application bundle and make it implement expected methods:

community class GrapeAppScreen extends Monitor 

   public GrapeAppScreen(@NonNull CarContext carContext) 

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

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

That must generate a easy display screen with our icon and title, now create another course extending CarAppService from the exact package and as very well make it put into practice the needed approaches. From createHostValidator() approach return a static a single that allows all hostnames for the goal of this tutorial and return model new session with our screen in onCreateSession(), pass CarContext making use of Session class getCarContext() method:

community course GrapeAppService extends CarAppService 

   community GrapeAppService() 

   community HostValidator createHostValidator() 
       return HostValidator.Enable_ALL_HOSTS_VALIDATOR

general public Session onCreateSession() 
   return new Session() 
       community Display screen onCreateScreen(@Nullable Intent intent) 
           return new GrapeAppScreen(getCarContext())

Next, shift to AndroidManifest and insert many functions inside the major manifest tag:

Within the Software tag add our services and action, really don’t fail to remember minCarApiLevel as deficiency of this will toss an exception on app start off:




Now we can upload our application to the system, confirm that you have an automotive emulator established, use automotive configuration, and strike operate. The app is run in Google Automotive Application Host, so if it is your 1st software on this product, it might require you to get to the play store and get it.

That is how it looks:

Build Your First App for Android Automotive OS

The past detail, we’ll include a navigation button that will pop a Toast. Modify onGetTemplate() in Display screen class, incorporate Action and ActionStrip:

Motion action = new Action.Builder()
               () -> CarToast.makeText(getCarContext(), "Howdy!", CarToast.Size_Small).display())
       .setTitle("Say hi!")

ActionStrip actionStrip = new 

Include it to PaneTemplate:

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

Which is our HelloWorld app:

Now you have the HelloWorld example application up and operating working with Auto App Library. It normally takes treatment of exhibiting and arranging every thing on the display for us. The only duty is to increase screens and actions we would like to have(and a bit of configuration). Look at the Motor vehicle application library to take a look at more of what can be finished with it, participate in about with creating your application, and certainly look at our weblog soon for extra AAOS app creation information.

Android Automotive OS