🌐
GitHub
github.com › lucasferreira › react-native-webview-android
GitHub - lucasferreira/react-native-webview-android: Simple React Native Android module to use Android's WebView inside your app
Simple React Native Android module to use Android's WebView inside your app - lucasferreira/react-native-webview-android
Starred by 356 users
Forked by 157 users
Languages   Java 86.2% | JavaScript 13.8%
🌐
GitHub
github.com › react-native-webview › react-native-webview
GitHub - react-native-webview/react-native-webview: React Native Cross-Platform WebView
React Native Cross-Platform WebView. Contribute to react-native-webview/react-native-webview development by creating an account on GitHub.
Starred by 7.1K users
Forked by 3.2K users
Languages   TypeScript 29.3% | Java 22.4% | Objective-C 16.9% | C++ 12.7% | Objective-C++ 8.0% | Kotlin 7.6%
🌐
npm
npmjs.com › package › react-native-webview-android
react-native-webview-android - npm
Simple React Native Android module to use Android's WebView inside your app. Latest version: 1.1.17, last published: 7 years ago. Start using react-native-webview-android in your project by running `npm i react-native-webview-android`. There ...
      » npm install react-native-webview-android
    
Published   Jul 06, 2018
Version   1.1.17
Author   Lucas Ferreira
🌐
npm
npmjs.com › package › react-native-webview
react-native-webview - npm
React Native WebView component for iOS, Android, macOS, and Windows. Latest version: 13.16.0, last published: 4 months ago. Start using react-native-webview in your project by running `npm i react-native-webview`. There are 1326 other projects in the npm registry using react-native-webview.
      » npm install react-native-webview
    
Published   Aug 25, 2025
Version   13.16.0
Author   Jamon Holmgren
🌐
Stack Overflow
stackoverflow.com › questions › 76893692 › how-to-specify-version-of-webview-implementation-to-be-used-in-android-app-is-t
react native - How to Specify version of WebView Implementation to be used in Android App? Is there a way to package a version of "Android System WebView" in APK - Stack Overflow
We have an Android Application built in React Native platform which loads a Web URL into a WebView. It imports the WebView component from the react-native-webview package. During runtime, we see that the Web URL is loaded on to the Android System ...
🌐
Expo Documentation
docs.expo.dev › versions › latest › sdk › webview
react-native-webview - Expo Documentation
A library that provides a WebView component. ... If you are installing this in an existing React Native app, make sure to install expo in your project.
🌐
Medium
medium.com › @pranavmore › how-to-build-a-simple-webview-app-using-expo-and-react-native-a16f4015467c
How to Build a Simple WebView App Using Expo and React Native | by Pranav more | Medium
January 27, 2025 - To generate an APK or an iOS build: npx expo prebuild npx expo run:android # For Android npx expo run:ios # For iOS (Mac required) Or, if using Expo’s managed workflow: npx expo build:android npx expo build:ios · Congratulations! 🎉 You’ve successfully built a WebView-based mobile app using Expo and React Native.
🌐
GitHub
github.com › react-native-webview › react-native-webview › blob › master › docs › Getting-Started.md
react-native-webview/docs/Getting-Started.md at master · react-native-webview/react-native-webview
React Native Cross-Platform WebView. Contribute to react-native-webview/react-native-webview development by creating an account on GitHub.
Author   react-native-webview
🌐
About React
aboutreact.com › home › react native webview
React Native WebView - About React
December 3, 2022 - React Native WebView is a component to render the web page to your mobile app. This is supported by Android and IOs both..
Find elsewhere
🌐
GitHub
github.com › react-native-webview › react-native-webview › blob › master › docs › Guide.md
react-native-webview/docs/Guide.md at master · react-native-webview/react-native-webview
React Native Cross-Platform WebView. Contribute to react-native-webview/react-native-webview development by creating an account on GitHub.
Author   react-native-webview
🌐
React Native Archive
archive.reactnative.dev › docs › webview
🚧 WebView · React Native Archive
Enables a custom native WebView which uses the same JavaScript as the original WebView.
Top answer
1 of 2
6

Ok so this is a complex issue. Basically, require() works fine with iOS and Android in debug modes but once you build a Android apk for release everything goes downhill. So I'll break this down into stages for posterity and, without a doubt, future me.

For setup, let's assume your file name is your.html and that it's located in your src/assets/your.html folder.

So step 1) You'll need to update your <WebView /> component with cross platform support in mind:

import {Platform, WebView} from 'react-native';    

<WebView
  source={Platform.OS === 'ios' ? 
    require('../src/assets/your.html') :
    {uri: 'file:///android_asset/your.html'}
  }
  domStorageEnabled
  javaScriptEnabled
/>

So what's going on here is that you need to tell android to allow access to dom storage and that you need javascript enabled (unless you don't then it's fine). Apparently, javascript is enabled by default on iOS and disabled by default on Android.

What source is doing here is, if the Platform is iOS, we just require files normally and everything will work for dev/prod. However, for android we need to tell it to load the file from the default android storage location for android which is file:///android_asset/. This file corresponds directly with the folder located at android/app/src/main/assets/ this is where your can copy your.html to. So it would look like android/app/src/main/assets/your.html.

And everything will work at this point - however, you might find copying your files directly incredibly annoying. At least, I did.

So for step 2) you can upgrade your app build.gradle file to automatically update your assets. So go ahead and open your app build.gradle file located at android/app/build.gradle. Somewhere towards the bottom (where other task commands are) go ahead and put:

task copyReactNativeHTML(type: Copy) {
  from '../../src/assets/'
  into 'src/main/assets'
}

gradle.projectsEvaluated {
  bundleDebugJsAndAssets.dependsOn(copyReactNativeHTML)
  bundleReleaseJsAndAssets.dependsOn(copyReactNativeHTML)
}

And now you should be able to have your files automatically copied into the correct assets folder so you can access them from javascript via android_asset.

And that's it! Kind of, it should work for most use cases but there is another strange thing about android and minifying your build with ProGuard. Basically, if you want to use it you need to make sure to keep your.html unmangled.

So for (optional) step 3) Open your proguard settings file located at android/app/proguard-rules.pro and add to it the following:

-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  public *;
}

And that's it, everything should be set for you to use WebViews crossplatform. I can't really take credit for this post as I just cobbled together a bunch of peoples solutions from https://github.com/facebook/react-native/issues/16133. In particular, Arshiamidos and scottschmitz solutions were most enlightening. I'd suggest we all go buy them a beer :).

2 of 2
0
 <WebView
  style={{
          flex: 1,
          marginLeft: Platform.OS === 'ios' ? 25 : 0,
          marginRight: Platform.OS === 'ios' ? 25 : 0,
          width: deviceWidth - 0,
          borderRadius: 4
          }}
          originWhitelist={['*']}
        source={Platform.OS === 'ios' ?
                require('../../../components/Heartrate.html') :
                {uri: 'file:///android_asset/Heartrate.html'}
                 }
         bounces={false}
         javaScriptEnabled={true}
         directionalLockEnabled={true}
         vertical={false}
         ref={(webView) => this.heartRateWebView = webView}
    />

In android Put Your Html in Android --> Asssets Folder

and iOS Put your Html in React Native Project inside your Folder

🌐
Stack Overflow
stackoverflow.com › questions › 74650174 › react-native-webview-is-not-working-on-android-after-generating-apk-or-aab
React Native Webview is not working on android after generating apk or aab - Stack Overflow
react-native-webview is working good on development. But, after generating apk or aab file, it's not working and just displaying a white screen as below. Please help to fix it. Here's my codes imp...
🌐
LogRocket
blog.logrocket.com › home › react native webview: a complete guide
React Native WebView: A complete guide - LogRocket Blog
August 12, 2024 - A web component can be anything from a simple HTML file to an entire webpage or application. The react-native-webview package is a WebView component for React Native that allows you to embed web content in React Native applications.
🌐
Instamobile
instamobile.io › react-native-tutorials › react-native-webview
React Native WebView Implementation | React Native App Templates ...
March 13, 2022 - Learn how to implement WebView in React Native applications for displaying web content.
🌐
Curiosum
curiosum.com › home › blog › react native › react native webview guide - build mobile app from existing web app
React Native WebView: Mobile App from Existing Web App Guide | Curiosum
December 5, 2023 - React Native WebView is a node package that introduces a WebView component that allows developers to display web content seamlessly within a React Native application. Earlier, the component was part of React Native, but now it's its package ...
🌐
DEV Community
dev.to › thebuildguy › how-to-use-webview-in-react-native-3gma
How to use WebView in React Native? - DEV Community
August 22, 2024 - A WebView is an embedded browser that can be used to display web pages inside your React Native... Tagged with reactnative, javascript, mobile.
🌐
Stack Overflow
stackoverflow.com › questions › tagged › react-native-webview
Newest 'react-native-webview' Questions - Stack Overflow
I'm building a React Native app using Expo (managed workflow) that loads a TradingView chart using WebView. It works perfectly in development mode (expo start) and in the development build (eas build -... android · react-native · apk · react-native-webview ·