Android Auto 应用程序未显示在物理设备上
目前正在测试 Android Auto,我们现在正在物理设备(汽车中)上进行测试。到目前为止,我已经成功地为应用程序添加了有效的 Android Auto 支持,我们正在其中绘制一些基本模板。这适用于模拟的 DHU,应用程序显示并可以使用。问题是,当我们在物理设备上测试时,它不会显示。我的应用程序当前显示在模拟的 DHU 中。所有必要的开发人员设置都已打开,因此这应该不是问题。
作为控制测试,我通过 Android Studio 创建了一个新项目,使用 >汽车>媒体服务,只是为了确保实际上可以在物理设备上进行测试。无需修改并在设备上进行全新安装,汽车即可识别该应用程序,并且可以通过电缆连接(物理设备)在汽车中使用该应用程序。
我怀疑在不同的清单中我忽略了一些东西。
这是项目应用程序的共享清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.itf_aa.shared">
<application>
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<meta-data android:name="androidx.car.app.minCarApiLevel"
android:value="1" />
<service
android:name="com.example.itf_aa.shared.MainGridService"
android:exported="true">
<intent-filter>
<action android:name="androidx.car.app.CarAppService" />
</intent-filter>
</service>
</application>
</manifest>
同时这是控制应用程序的共享清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication.shared">
<application android:appCategory="audio">
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<!-- Main music service, provides media browsing and media playback services to
consumers through MediaBrowserService and MediaSession. Consumers connect to it through
MediaBrowser (for browsing) and MediaController (for playback control) -->
<service
android:name="com.example.myapplication.shared.MyMusicService"
android:exported="true">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>
</application>
我怀疑问题出在意图过滤器中,其中似乎是差异制造者。有谁知道我是否可以在意图过滤器中使用其他任何东西,或者我的清单可能是错误的?这是我唯一怀疑是差异制造者的事情,因为我看不出应用程序类别如何使其与众不同。 为什么当我们使用“android.media.browse.MediaBrowserService”时,应用程序会显示物理设备,而当我们使用“androidx.car.app.CarAppService”时,应用程序不会显示物理设备?
我很感谢您提供的任何帮助可能会解决这个问题,所以提前感谢您的时间和帮助。如果我遗漏了某些内容或者您需要更多详细信息,请告诉我。 ❤️
Currently testing Android Auto, where we are now testing on a physical device (in a car). So far I have managed to get add working Android Auto support to an app, where we are drawing some basic templates. This works on the emulated DHU and the app shows and can be used. The problem is that when we are testing on a physical device, it doesn't show up. My app currently shows up in the emulated DHU. All the necessary developer settings are turned on, so this shouldn't be an issue.
As a control test I created a new project through Android Studio by using > Automotive > Media Service, just to make sure that it was actually possible to test on a physical device. With no modifications and a clean install on a device, the car recognizes the app and the app is available in the car through a cable connection (physical device).
I suspect there is something I am overlooking in the different manifests.
This is the shared manifest for the project app:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.itf_aa.shared">
<application>
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<meta-data android:name="androidx.car.app.minCarApiLevel"
android:value="1" />
<service
android:name="com.example.itf_aa.shared.MainGridService"
android:exported="true">
<intent-filter>
<action android:name="androidx.car.app.CarAppService" />
</intent-filter>
</service>
</application>
</manifest>
Meanwhile this is the shared manifest of the control app:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication.shared">
<application android:appCategory="audio">
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<!-- Main music service, provides media browsing and media playback services to
consumers through MediaBrowserService and MediaSession. Consumers connect to it through
MediaBrowser (for browsing) and MediaController (for playback control) -->
<service
android:name="com.example.myapplication.shared.MyMusicService"
android:exported="true">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>
</application>
I suspect the problem is found in the intent filter, where seems to be the difference maker. Does anyone know if there is anything else I can use in the intent filter or how my manifests may be wrong? This is the only thing I suspect being the difference maker, as I don't see how the app category makes it any different. Why does the app show up physical devices when we use "android.media.browse.MediaBrowserService", but not when we use "androidx.car.app.CarAppService"?
I am grateful for any help I might get on this, so thank you for your time and help in advance. If I left something out or you need more details, let me know. ❤️
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,可以在此处找到答案。
回答:为了在物理设备上进行测试,您需要启动内部测试轨道并接受 Android Auto 附录。然后通过开发者控制台部署测试。
它与清单无关。仍然不确定为什么示例项目会绕过这个,但一定是 Google 应用程序的某种白名单。
Turns out the answer can be found here.
Answer: in order for testing on physical devices, you need to start an internal test track and accept the Android Auto addendum. Then deploy the test through the Developer Console.
It had nothing to do with the manifests. Still not sure why sample projects bypass this, but must be some sort of whitelist for Google apps.