问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/51929882/google-play-warning-about-missing-leanback-intent