Flutter Android TV应用主页无启动横幅图标问题求助
解决方案
1. 修正横幅图标规格与资源
Android TV的横幅图标有严格的尺寸要求,不能使用自适应图标(mipmap下的ic_launcher通常是自适应图标),必须使用固定比例的横幅图:
- 基础尺寸:320x180像素(mdpi)
- 对应dpi适配:
- hdpi:480x270
- xhdpi:640x360
- 格式推荐PNG,将图标放在
drawable目录(按dpi分目录:drawable-mdpi、drawable-hdpi等),命名为banner.png。
2. 完善AndroidManifest.xml配置
必须添加TV专属的启动Intent Filter,同时指定正确的横幅资源:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <application android:label="yfplayer" android:name="${applicationName}" android:icon="@mipmap/ic_launcher" android:banner="@drawable/banner"> <!-- 指定单独的横幅图标 --> <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize"> <!-- 手机端启动入口 --> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> <!-- TV端必备启动入口(核心:LEANBACK_LAUNCHER) --> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LEANBACK_LAUNCHER"/> </intent-filter> </activity> </application> </manifest>
3. 确保应用兼容TV设备
- 在app级
build.gradle中添加TV依赖:dependencies { implementation "androidx.leanback:leanback:1.0.0" } - 移除或修改触摸屏强制依赖(如果存在):
<!-- 错误写法:TV无触摸屏,会导致应用被TV排斥 --> <uses-feature android:name="android.hardware.touchscreen" android:required="true"/> <!-- 正确写法 --> <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
4. 清理缓存并重建项目
执行以下命令清理缓存后重新构建安装:
flutter clean flutter build apk --target-platform android-arm64 # 或直接运行到TV设备 flutter run -d <你的TV设备ID>
内容的提问来源于stack exchange,提问作者Yuseferi
相关产品推荐
相关产品推荐

