Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Play warning about missing leanback intent

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?

like image 883
Andrew Parker Avatar asked Aug 20 '18 11:08

Andrew Parker


1 Answers

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.

like image 173
tomasznajda Avatar answered Oct 18 '22 08:10

tomasznajda