Norlihazmey Ghazali Norlihazmey Ghazali - 1 year ago 71
Android Question

Webview not showing any content(html) react native

Contents did showing up perfectly inside emulator and debug with real device but does not showing anything when testing out with real device (using released .apk). It just only showed blank container with white color. Or do i missed something?

<WebView
ref={(wView) => {this.wView = wView}}
javaScriptEnabled={true}
// onBridgeMessage={this.onBridgeMessage}
onMessage={this.onMessage}
injectedJavaScript="window.postMessage = String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage');"
automaticallyAdjustContentInsets={false}
domStorageEnabled={true}
startInLoadingState={true}
source={mainHtml} <-- load with, var mainHtml = require('./MainHtml.html');
style={{width: 320,height:100,flex: 1}}/>


Environment


  • react-native-cli: 2.0.1

  • react-native: 0.43.4

  • react: 16.0.0-alpha.6

  • Device(ASUS Zenfone)

  • Android version 6.0.1


Answer Source

From what I've read here this is a known issue with Android when deploying in Release. The workaround is to point to the file with a uri:

{ uri: 'file:///pathto/file.html' }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download