WebView source={require(xxx.html)} is not working on Android Release
See original GitHub issueIs 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:)
- create
index.html
<html>
<head>
<title>Title</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
- modify
index.ios.js
andindex.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);
- Build Release APK
- Run On Android
Expected Behavior
Hello World
show up on screen.
Actual Behavior
Nothing. Just Blank Screen
Reproducible Demo
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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)
+1 for the same behavior on Android as is on iOS