React Native Android app that uses websockets is crashing as webview is not loaded
See original GitHub issueEnvironment
Run react-native info
in your terminal and paste its contents here.
React Native Environment Info:
System:
OS: Windows 10
CPU: x64 Intel® Core™ i7-7820HQ CPU @ 2.90GHz
Memory: 8.46 GB / 31.81 GB
Binaries:
Yarn: 1.9.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.1.0.0 AI-173.4907809
Description
Describe your issue in detail. Include screenshots if needed. If this is a regression, let us know. React native app with WebSockets runs fine on Android Virtual Device, but fails with following error message stack trace on physical android device.Not sure why WebView is in the picture here as I dont explicitly use it anywhere in the code
" This error can also happen due to a require() error during initialization or failure to call AppRegistry.registerComponent. E/WebViewFactory: Chromium WebView package does not exist"
“android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed”
Caused by: android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed at android.webkit.WebViewFactory.getWebViewContextAndSetProvider(WebViewFactory.java:319) at android.webkit.WebViewFactory.getProviderClass(WebViewFactory.java:383) at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:194) at android.webkit.CookieManager.getInstance(CookieManager.java:39) at com.facebook.react.modules.network.ForwardingCookieHandler.getCookieManager(ForwardingCookieHandler.java:161) at com.facebook.react.modules.network.ForwardingCookieHandler.get(ForwardingCookieHandler.java:59) at okhttp3.JavaNetCookieJar.loadForRequest(JavaNetCookieJar.java:59) at com.facebook.react.modules.network.ReactCookieJarContainer.loadForRequest(ReactCookieJarContainer.java:42) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:84) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:147) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)
Reproducible Demo
Any React native project using standard out of box websockets. React native app deployed to device using command “react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android”
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
react-native uses okhttp WebSockets. The problem root cause is that your device is missing WebView for some reason.
react-native replaces okhttp cookies manager with the android’s ForwardingCookieManager which relies on WebView. (Probably to share the cookies with WebView?)
We are seeing this crash in production too. There is only a small fraction of devices have no WebView.
This issue has been moved to react-native-community/react-native-webview#432.