react-native-webview not working with SDK 47 Android Build

SDK Version: 47
Platforms: Android
Build: AES
Package and Version: react-native-webview version 11.23.1
Installation: npx expo install react-native-webview

Notes

  • Expo Go with react-native-webview works fine.
  • Actual android build crashes with the error: “TypeError: null is not an object (evaluating ‘_reactNative.NativeModules.RNCWebView.isFileUploadSupported’)”

Steps to Reproduce:

  • Step 1: npx create-expo-app my-app
  • Step 2: Add WebView from example in main App.js: WebView - Expo Documentation
  • Step 3: Create EAS Android (recommend developmentClient: true in your profile to see the error)
  • Start expo app using yarn start and load build in your development client android build.
    • Just a reminder it works in ExpoGo but not in the actual build.

Hi @jeremykpagley

I was not able to reproduce the problem.

I did this:

  • yarn create expo-app
    I use yarn for managing dependencies, and I see in a later step you used yarn start too
  • Following the WebView docs, I ran npx expo install react-native-webview and then added some sample code to App.js:
import 'expo-dev-client';
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import { WebView } from 'react-native-webview';

export default function App() {
  return (
    <WebView
      style={styles.container}
      source={{ uri: 'https://expo.dev' }}
    />
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});
  • I also ran npx expo install expo-dev-client and imported it at the top of App.js
  • I created a dev build with eas build -p android --profile development
  • I installed the dev build on the Android emulator
  • I ran npx expo start in the terminal and manually entered the URL in the dev build
  • It loaded without complaint and showed the Expo home page in the WebView
2 Likes

@wodin Thank you so much for trying this out for me!

I was convinced something was wrong with the react-native-webview module lol

The module working for you made me think that maybe it had something to do with my environment and not the module. This caused me to look into what version of node, npx, yarn, etc. I moved to Node v18+ (I was previously on Node 14) and that upgraded me to NPX v8.19.2. After that I went through the same steps you and I both listed and it worked!!! :tada:

This is the only change I made and it worked just like you said!

I greatly appreciate your time and help with this :blush:

1 Like