We are trying to publish an Android Automotive app, but have some issues extending the CarAppService.
Disclaimer: I am very new to Android Automotive, so there might be an obvious answer to this question.
The code we are working on was developed by a previous team (which we don´t have contact with), and they have used Jetpack Compose for the application. Instead of CarAppService, they have used MainActivity, and instead of onGetTemplate, they have used setContent (code snippet below).
The function in MainActivity which implements the main component (Calculator())
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
carInfo = fetchCarInfo()
fetchUxRestrictions()
setContent {
Theme {
Calculator(this, isCarRestrictionNoSetup)
}
}
}
From the AndroidManifest.xml file:
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="androidx.car.app.category.POI" />
</intent-filter>
<meta-data android:name="distractionOptimized" android:value="true" />
</activity>
I have found very little documentation on the use of Jetpack Compose for Android Automotive, and in this video https://android-developers.googleblog.com/2021/03/android-auto-apps-powered-by-jetpack.html, at 09:38, its stated that "[...] currently and probably for forseeable future, you can only build apps relied on templates".
In the examples I have found online with CarAppService, onGetTemplate is always used to build and style the Android Automotive application.
After some research, I am growing certain that we can't use Jetpack Compose for the application, and that it has to be built on the predefined templates. If that is the case, my concern is that we have to scrap the code the previous team wrote and start over, which is why I want to ask here before I do anything.
My question is, is it possible to use Jetpack Compose to style an Android Automotive application, or do we have to use the templates?
In general, it is not possible to use Jetpack Compose to write an application for Android Automotive OS that will be distributed via the Play Store. There are a few exceptions to this however:
One thing to note is that only the following category of apps are currently permitted on the Play Store for Android Automotive OS
(see Supported app categories for more details/up-to-date information)