Android-TV应用显示白色屏幕

时间:2018-08-06 12:38:05

标签: android react-native expo android-tv

我已经用react-native和expo构建了一个App。将其安装在我的Android-TV和Android-TV模拟器上。

当我通过ES File Explorer应用程序运行该应用程序时,该应用程序可以运行,但是当我尝试通过在Android-TV应用程序部分中单击该应用程序定期运行该应用程序时,则会显示恒定的白屏。

通过$ exp build:android构建带有expo的apk。 App.json代码:

 {
  "expo": {
    "name": "CommuniTV",
    "description": "The future of watching TV is here!",
    "slug": "CommuniTV",
    "privacy": "public",
    "sdkVersion": "26.0.0",
    "platforms": ["ios", "android"],
    "version": "1.0.4",
    "orientation": "landscape",
    "entryPoint": "./App.js",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "package": "project.communiTV.com",
      "versionCode": 104,
      "permissions": [],
      "icon": "./AppIcon.png",
      "adaptiveIcon": {
        "foregroundImage": "./launcherIcon.png" // size is 1024x1024
      }
    }
  }
}

在网络上找不到任何解决方案,我被困住了。

有什么建议吗? First screenshot - I click here I get a white screen

Second screenshot - I'll start it from here the App works fine

3 个答案:

答案 0 :(得分:2)

花了一些时间查看本机代码后,我设法通过向app.json添加适当的配置来解决此问题:

"android": {
  ...
  "intentFilters": [
    {
      "action": "MAIN",
      "category": [
        "LEANBACK_LAUNCHER"
      ]
    }
  ]
},

更详细的答案可以在这里找到:https://gist.github.com/miazga/2e6449e0c591e3ac8e22185b2edb447d

答案 1 :(得分:0)

按照此thread的建议,Go to File-> Setting-> Build,Execution,Deployment-> Instant Run,然后取消选中Enable Instant Run选中,然后运行项目。

同样从此link开始,当您的应用启动时,它首先使用启动活动的主题来显示窗口背景。如果未在windowBackground中指定styles.xml,则将使用默认的白色,并且会损坏UX。

答案 2 :(得分:0)

到目前为止,Matt 的答案似乎已经过时,它在读取清单时抛出构建时间错误。

TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at renderIntentFilterDatumEntries (/app/turtle/node_modules/@expo/xdl/build/detach/AndroidIntentFilters.js:33:17)
    at /app/turtle/node_modules/@expo/xdl/build/detach/AndroidIntentFilters.js:37:70
    at Array.map (<anonymous>)
    at renderIntentFilterData (/app/turtle/node_modules/@expo/xdl/build/detach/AndroidIntentFilters.js:37:48)
    at /app/turtle/node_modules/@expo/xdl/build/detach/AndroidIntentFilters.js:25:9
    at Array.map (<anonymous>)
    at renderIntentFilters (/app/turtle/node_modules/@expo/xdl/build/detach/AndroidIntentFilters.js:22:24)
    at runShellAppModificationsAsync (/app/turtle/node_modules/@expo/xdl/build/detach/AndroidShellApp.js:632:115)
    at async Object.createAndroidShellAppAsync (/app/turtle/node_modules/@expo/xdl/build/detach/AndroidShellApp.js:392:3)
    at async runShellAppBuilder (/app/turtle/build/builders/android.js:95:9)
    at async Object.buildAndroid [as android] (/app/turtle/build/builders/android.js:43:28)
    at async build (/app/turtle/build/jobManager.js:181:33)
    at async processJob (/app/turtle/build/jobManager.js:118:32)
    at async Object.doJob (/app/turtle/build/jobManager.js:49:5)
    at async main (/app/turtle/build/server.js:66:13)

我用 data 属性更新了它,现在似乎工作正常,在 39 和 40 世博会测试

另请注意,您必须在类别中也包含“LAUNCHER”,否则某些设备可能仍会显示白屏。

"intentFilters": [
        {
          "action": "MAIN",
          "data":{},
          "category": [
            "LEANBACK_LAUNCHER",
            "LAUNCHER"
          ]
        }
      ]