question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebView source={require(xxx.html)} is not working on Android Release

See original GitHub issue

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment: OS: macOS Sierra 10.12.6 Node: 6.10.3 Yarn: 0.24.5 npm: 3.10.10 Watchman: 4.7.0 Xcode: Xcode 9.0 Build version 9A235 Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed) react: 16.0.0-alpha.12 => 16.0.0-alpha.12 react-native: 0.48.4 => 0.48.4

Steps to Reproduce

(Write your steps here:)

  1. create index.html
<html>
    <head>
        <title>Title</title>
    </head>
    <body>
        <h1>Hello World</h1>
    </body>
</html>
  1. modify index.ios.js and index.android.js
/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  WebView,
  View
} from 'react-native';

export default class WebViewTest extends Component {
  render() {
    return (
      <View style={styles.container}>
        <WebView
          scalesPageToFit={true}
          source={require('WebViewTest/index.html')}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

AppRegistry.registerComponent('WebViewTest', () => WebViewTest);
  1. Build Release APK
  2. Run On Android

Expected Behavior

Hello World show up on screen.

Actual Behavior

Nothing. Just Blank Screen

Reproducible Demo

https://github.com/yosimasu/WebViewTest

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
SoloXCRacercommented, Dec 18, 2017

Issue still occurs on Android. This needs to work the same as on iOS for the same reasons as people have stated above. This is obviously a bug and it is easily reproduce-able (see https://github.com/facebook/react-native/issues/7924)

7reactions
brancooo1commented, Oct 11, 2017

+1 for the same behavior on Android as is on iOS

Read more comments on GitHub >

github_iconTop Results From Across the Web

bundle local html files for android webview
I tried this: source= {require('file.html')} It works perfectly in debug version of ios and android, however after release, android shows white ...
Read more >
Android WebViews - Apache Cordova
This guide shows how to embed a Cordova-enabled WebView component within a larger Android application. For details on how these components can communicate ......
Read more >
WebView/HTTP Connection not working in Release Mode
Hi to all, I'm working on a cross-platform (UWP & Android) app. Testing it in Release mode, the WebView is not able to...
Read more >
Mobile Application Security & Privacy - Ostorlab's
This article is about WebViews and the security notions we need to have in mind when using these component in both Android and...
Read more >
Android System WebView: How to Disable It or Troubleshoot
If you have an older version Android phone running Android 7.0 Nougat, Android 8.0 Oreo, or Android 9.0 Pie, you can disable the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found