【问题标题】:Android-TV app shows white screenAndroid-TV 应用显示白屏
【发布时间】:2019-01-13 10:13:17
【问题描述】:

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

当我通过 ES 文件资源管理器应用程序运行该应用程序时,它可以工作,但是当我尝试通过在 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

【问题讨论】:

    标签: android react-native expo android-tv


    【解决方案1】:

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

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

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

    【讨论】:

      【解决方案2】:

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

      同样来自这个link,当你的应用启动时,它首先使用启动活动的主题来显示窗口背景。如果您没有在styles.xml 中指定windowBackground,则会使用默认的白色,并损坏用户体验。

      【讨论】:

      • 这不是我的应用程序的问题。该应用程序无法加载,它会一直保持白屏,直到我退出该应用程序...但是通过带有启动图标且根本没有白屏的 ES 文件资源管理器可以正常工作。
      【解决方案3】:

      到目前为止,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 属性对其进行了更新,现在似乎工作正常,在 expo 39 & 40 上测试

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-25
        • 1970-01-01
        • 2013-10-30
        相关资源
        最近更新 更多