How to utilize Android Car API inside an app

后端 未结 2 1701
一整个雨季
一整个雨季 2020-12-18 09:22

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.*

相关标签:
2条回答
  • 2020-12-18 09:59

    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.

    0 讨论(0)
  • 2020-12-18 10:11

    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

    0 讨论(0)
提交回复
热议问题