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?
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.
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.
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.
The library is now released as part of Android Q SDK in Android Studio. You need to
update the SDK 29 to minor version 5 using SDK manager
Update app module build.gradle include car-lib
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
...
useLibrary 'android.car'
}
API documentation is available here
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With