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.

Expo WebView Android doesn't work

See original GitHub issue

🐛 Bug Report

WebView Android doesn’t work

The problem is that when I use WebView and want to load some html page or custom HTML with external .js files it is not shown on Android. It works with simple HTML tags but not when I use param - uri.

I have no problem with same code for iPhone XR but for Android there are a error:

Error loading page Domain: undefined Error Code: -1 Desctiption: net:ERR_CACHE_MISS

Environment

Expo CLI 3.21.5 environment info: System: OS: Windows 10 10.0.18363 Binaries: Node: 12.16.1 - C:\Program Files\nodejs\node.EXE npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 3.5.0.0 AI-191.8026.42.35.6010548 npmPackages: expo: ~37.0.3 => 37.0.12 react: ~16.9.0 => 16.9.0 react-dom: ~16.9.0 => 16.9.0 react-native: https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz => 0.61.4 react-native-web: ~0.11.7 => 0.11.7

System: OS: Windows 10 10.0.18363 CPU: (4) x64 Intel® Core™ i7-5500U CPU @ 2.40GHz Memory: 3.22 GB / 7.90 GB Binaries: Node: 12.16.1 - C:\Program Files\nodejs\node.EXE npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 3.5.0.0 AI-191.8026.42.35.6010548 npmPackages: react: ~16.9.0 => 16.9.0 react-native: https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz => 0.61.4 npmGlobalPackages: react-native-cli: 2.0.1

The code

import React from 'react';
 
import { WebView } from 'react-native-webview';

export default function App() {
  return (
        <WebView 
          automaticallyAdjustContentInsets={false}
          source={{ uri: 'https://expo.io' }} 
          style={{ marginTop: 80, width: 300, height: 250 }} 
          originWhitelist={["*"]}
          javaScriptEnabled={true}
          startInLoadingState={true}
          mixedContentMode={'always'}
          thirdPartyCookiesEnabled={true}
          scrollEnabled={true}
          domStorageEnabled={true}
          allowUniversalAccessFromFileURLs={true}
          javaScriptEnabled={true}
        />
  );
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
msama1commented, Jul 26, 2020

The same problem with android 5.0.1 and expo SDK 38 but it works fine on emulator with android 7 and same SDK

any updates regarding this issue?

0reactions
patryklubacommented, Jun 17, 2020

I have the same problem.

Phone 1: ASUS_X014D Android: 5.1.1

Phone 2: Huawei P smart 2019 Android: 10

The code: <WebView style={{ flex: 1 }} source={ Platform.OS === "ios" ? require("../../assets/map.html") : { uri: __DEV__ ? DEV_INDEX_FILE_ASSET_URI : INDEX_FILE_ASSET_URI } } originWhitelist={["*"]} ref={ref => (this.context.webView = ref)} javaScriptEnabled={true} mixedContentMode={"always"} onMessage={this.handleMessage} onLoadEnd={this.sendConnected} onLoad={this.loadEnd} />

System: Expo CLI 3.21.5 environment info: System: OS: Linux 4.15 Linux Mint 19.2 (Tina) Shell: 5.4.2 - /bin/zsh Binaries: Node: 13.14.0 - /usr/bin/node npm: 6.14.4 - /usr/bin/npm npmPackages: expo: ^36.0.0 => 36.0.2 react: 16.9.0 => 16.9.0 react-dom: ^16.12.0 => 16.13.1 react-native: 0.61.5 => 0.61.5 react-navigation: ^2.12.1 => 2.18.3 npmGlobalPackages: expo-cli: 3.21.5

Is available resolve?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webview not appearing in Expo Web - Stack Overflow
Working fine in expo mobile app, but same code doesn't show anything when opening Expo App on Web browser by running command expo...
Read more >
WebView - Expo Documentation
react-native-webview provides a WebView component that renders web content in a native view. Platform Compatibility. Android Device, Android Emulator, iOS ...
Read more >
React Native WebView: A complete guide - LogRocket Blog
React Native WebView renders web content in a native view. Learn some of its tricks and features that you can use to your...
Read more >
4 Problems that You Need to Know Before Using React Native ...
Problem 3: Importing local HTML File in webview [Android] ... Importing local HTML files inside webview differs between expo and bare react native....
Read more >
How to use WebView in React Native - Educative.io
Make sure AndroidX is enabled in your project by editing android/gradle.properties . android.useAndroidX=true android.
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