简体   繁体   中英

Android-TV app shows white screen

I've built an App with react-native and expo. Installed it on my Android-TV and my Android-TV emulator.

The app works when I run it through the ES File Explorer app, however when I try to run it regularly by clicking it on the Android-TV app section I get a constant white screen.

Built the apk with expo through $exp build:android. App.json code:

 {
  "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
      }
    }
  }
}

Couldn't find any solution on the web and I'm stuck.

Any suggestions? First screenshot - I click here I get a white screen

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

After spending some time looking at the native code I managed to solve this issue by adding the proper configuration to app.json:

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

More detailed answer can be found here:https://gist.github.com/miazga/2e6449e0c591e3ac8e22185b2edb447d

As recommended in this thread , Go to File -> Setting -> Build,Execution,Deployment -> Instant Run then uncheck the Enable Instant Run if it is checked, then run the project.

Also from this link , when your app starts, it first uses the theme of the launching activity to display the window background. If you don't specify windowBackground in your styles.xml , the default white will be used, and damage the UX.

Matt's answer seems to be oudated as of now, its throwing build time error while reading manifest.

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)

I updated it with data property, now seems to work fine, tested on expo 39 & 40

Also note that you have to include "LAUNCHER" too in category or else some devices may still show white screen.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM