Make Android Auto an opt-in build flag

Android Auto support is now merged into the app only when building with
-PandroidAuto=true (flutter build apk --android-project-arg=androidAuto=true).
The car application meta-data and automotive_app_desc.xml move to
android/app/src/androidAuto/, so default builds no longer declare Android
Auto. Notification replies from the shade and watches are unchanged.
This commit is contained in:
zjs81 committed 2026-10-24 20:22:12 -07:00
1 parent caee4d5c19
commit fe7e72a421
6 files changed
+38 -7

No files matched your search

+18
View File
@@ -98,6 +98,24 @@ android {
// }
}
// Android Auto (notification read-aloud and voice reply) is opt-in, because
// declaring it puts the app through Play's separate Android Auto review.
// Enable it with `flutter build apk --android-project-arg=androidAuto=true`
// or `./gradlew -PandroidAuto=true ...`.
val androidAutoEnabled = (findProperty("androidAuto") as String?)?.toBoolean() == true
if (androidAutoEnabled) {
android.sourceSets.getByName("main").res.srcDir("src/androidAuto/res")
}
androidComponents {
onVariants { variant ->
if (androidAutoEnabled) {
variant.sources.manifests.addStaticManifestFile("src/androidAuto/AndroidManifest.xml")
}
}
}
flutter {
source = "../.."
}
@@ -0,0 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Merged only when built with -PandroidAuto=true; see app/build.gradle.kts -->
<application>
<!-- Android Auto: message notifications can be read aloud and replied to -->
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
</application>
</manifest>
-4
View File
@@ -34,10 +34,6 @@
<receiver
android:name="com.dexterous.flutterlocalnotifications.ActionBroadcastReceiver"
android:exported="false" />
<!-- Android Auto: message notifications can be read aloud and replied to -->
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<activity
android:name=".MainActivity"
android:exported="true"