Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to utilize Android Car API inside an app

I want to test and (if possible) utilize Android Car API functionalities inside my Android app. Specifically, I need to be able to import classes under android.car.* package which can be seen here: https://developer.android.com/reference/android/car/packages.html

I also found the repo on Google Git: https://android.googlesource.com/platform/packages/services/Car/

How should I add this library as a dependency in my app?

like image 446
Ugurcan Yildirim Avatar asked Mar 12 '19 16:03

Ugurcan Yildirim


People also ask

Is Android Auto a built in app?

Starting with Android 10, Android Auto is built into the phone as a technology that enables your phone to connect to your car display. This means you no longer have to install a separate app from the Play Store to use Android Auto with your car display.

How do I connect apps to Android Auto?

Once you've downloaded the apps you'd like to use, open Android Auto on your smartphone and select Customize launcher under the General settings. From there, you'll see a list of compatible apps. Check the box beside the ones you want to appear on your car's display while using Android Auto.

What actions can users control via Android Auto?

Android Auto brings apps to your car display so you can focus while you drive. You can control features like navigation, maps, calls, text messages, and music. To get more information about your car's compatibility with Android Auto on your car display, contact your vehicle manufacturer.


2 Answers

The library is now released as part of Android Q SDK in Android Studio. You need to

  1. update the SDK 29 to minor version 5 using SDK manager

  2. Update app module build.gradle include car-lib

    android {
         compileSdkVersion 29
         buildToolsVersion "29.0.3"
         ...
         useLibrary 'android.car'
    }
    
  3. API documentation is available here

like image 68
Selim Gurun Avatar answered Oct 01 '22 01:10

Selim Gurun


Edit: This answer is outdated. Use the method in the accepted answer now that the tooling has been updated and the lib is part of the platform.

There's no prebuilt binary for android.car, but you can build it yourself by running mm in packages/services/Car/car-lib: https://android.googlesource.com/platform/packages/services/Car/+/refs/heads/master/car-lib/Android.bp#50

If your app has an .mk or .bp file, you can include the library like CarService does here: https://android.googlesource.com/platform/packages/services/Car/+/master/service/Android.mk#42

The library is mostly meant for OEMs though and not so much for third parties.

like image 41
fejd Avatar answered Oct 01 '22 00:10

fejd