How to utilize Android Car API inside an app

一曲冷凌霜 提交于 2020-12-23 02:21:02

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/55125921/how-to-utilize-android-car-api-inside-an-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!