Google Play warning about missing leanback intent
Asked Answered
M

1

6

When updating our app on Google Play I get

You opted-in to Android TV but your APK or Android App Bundle does not have the Leanback intent

This is somewhat bizarre as we have all the required components in our manifest to support TV, namely:

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

and

    <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>

and

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

(Note that we share the activity between TV and mobile)

We include the following gradle modules as well:

implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:leanback-v17:27.1.1'

The app also works on TV devices :)

Now, admittedly we've done a big refactor so the structure of our app and manifest has changed a lot. However, I don't see anything that contradicts the requirements in the Android development docs:

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

Has anyone experienced this? Alternatively, can anyone see anything else obvious which is missing/incorrect?

Messieurs answered 20/8, 2018 at 11:32 Comment(3)
Your Launcher activity must have <category android:name="android.intent.category.LEANBACK_LAUNCHER" /> in your <intent-filter> of that activityPinnatipartite
Please see above. I am already doing this. This was included in my original post.Messieurs
shouldn't be the android:name="android.software.leanback" be set to "true"?Malcolm
F
2

Finally I found out the answer!

If you want to support AndroidTV you cannot lock orientation inside manifest.

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

Instead, you can use below code (or something similar) inside Activity's onCreate

requestedOrientation =
        if (isPhoneDevice()) ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
        else ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE

If there is no locking orientation logic in your manifest maybe some lib adds it. Decompile your apk using apk tool and then verify generated manifest. You can replace it with this code:

<activity
            android:name="com.yoursite.SampleActivity"
            tools:replace="android:screenOrientation"
            tools:node="merge"
            android:screenOrientation="sensor"/>

I hope it will help :)

EDIT: I found out another problem.

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

You cannot use ACCESS_WIFI_STATE permission on Android TV.

Feldman answered 29/8, 2018 at 7:35 Comment(2)
Thanks for your response. I tried removing ACCESS_WIFI_STATE and no luck. I also checked orientation (in the decompiled apk) and the only time we set that attribute we use android:screenOrientation="behind" (albeit on a lot of activities). Our app is definitely reaching TVs, just no idea why that message is there.Messieurs
Try to compare your manifest from google play with the new one. Maybe there is at least one permission or hardware that is not supported on Android TV. List of prohibited features you can find here: developer.android.com/training/tv/start/hardware, but remember that it is not all of them. My app has been successfully updated (for android tv too) after removing wifi permission and locking screen orientation.Feldman

© 2022 - 2024 — McMap. All rights reserved.