谷歌Play警告缺少Leanback意图

6
在更新我们的Google Play应用程序时,我遇到了问题。
You opted-in to Android TV but your APK or Android App Bundle does not have the Leanback intent

这有点奇怪,因为在我们的清单中已经包含了所有支持电视所需的组件,即:

<uses-feature
    android:name="android.software.leanback"
    android:required="false" />
<uses-feature
    android:name="android.hardware.touchscreen"
    android:required="false" />

并且

    <activity
        android:name=".MainActivity"
        android:configChanges="orientation"
        android:launchMode="singleTop"
        android:screenOrientation="behind"
        android:theme="@style/AppTheme.Splash">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
        </intent-filter>
    </activity>

并且

<application
    android:banner="@drawable/tv_banner"

(Note that we share the activity between TV and mobile)
我们还包括以下Gradle模块:
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:leanback-v17:27.1.1'

该应用程序也适用于电视设备 :)
现在,诚然我们已经进行了一次大的重构,因此我们应用程序和清单的结构发生了很大变化。但是,我没有看到任何与Android开发文档中的要求相矛盾的地方:

https://developer.android.com/training/tv/start/start

有人经历过这种情况吗?或者还有其他明显缺失/错误的地方吗?

1
您的启动器活动必须在该活动的<intent-filter>中有<category android:name="android.intent.category.LEANBACK_LAUNCHER" />。 - Manoj Patidar
请看上方。我已经在做这件事了。这已经包含在我的原始帖子中了。 - Andrew Parker
难道android:name="android.software.leanback"不应该设置为"true"吗? - Rahul Shukla
1个回答

2

终于我找到了答案!

如果你想支持AndroidTV,你不能在清单文件中锁定方向。

android:screenOrientation="landscape"
android:screenOrientation="portrait"

相反,您可以在Activity的onCreate方法中使用以下代码(或类似代码):
requestedOrientation =
        if (isPhoneDevice()) ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
        else ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE

如果您的清单文件中没有锁定方向的逻辑,可能是某个库添加了它。使用apk工具反编译您的apk,然后验证生成的清单文件。您可以将其替换为以下代码:
<activity
            android:name="com.yoursite.SampleActivity"
            tools:replace="android:screenOrientation"
            tools:node="merge"
            android:screenOrientation="sensor"/>

我希望这能帮到你 :) 编辑: 我发现另一个问题。
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

你不能在Android TV上使用ACCESS_WIFI_STATE权限。


感谢您的回复。我尝试移除ACCESS_WIFI_STATE,但是没有改善。我还检查了方向(在反编译的apk中),我们设置属性的唯一时间是使用android:screenOrientation="behind"(虽然在很多活动中)。我们的应用程序肯定可以到达电视,只是不知道为什么会出现那个消息。 - Andrew Parker
尝试将您在Google Play上的清单与新的进行比较。也许有至少一个权限或硬件不支持Android TV。您可以在此处找到禁止使用的功能列表:https://developer.android.com/training/tv/start/hardware,但请记住这并不是全部。在删除WiFi权限和锁定屏幕方向后,我的应用程序已成功更新(适用于Android TV)。 - tomasznajda

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接