Skip to content

Commit 954f715

Browse files
thorbenprimkefacebook-github-bot
authored andcommitted
Adds Logic To Catch MissingWebViewPackageException (#24533)
Summary: We are seeing crash reports that the webview is missing. In this case it should fail gracefully so that a missing webview does not block from using an app built with React Native. The contains could also be changed to check for "webview" in general to catch all webview related exception. It's currently checking on for the specific string that I'm seeing in our app's crashreporting tool. <img width="1507" alt="Screen Shot 2019-04-19 at 11 26 19 AM" src="https://user-images.githubusercontent.com/741767/56438307-5e1c2f80-6297-11e9-970b-a5095d18e9d7.png"> <img width="935" alt="Screen Shot 2019-04-19 at 11 32 58 AM" src="https://user-images.githubusercontent.com/741767/56438213-fa920200-6296-11e9-8008-5eb344eca8a8.png"> [Android] [Fixed] - The ReactCookieJarContainer/ForwardingCookieHandler now handles the missing WebView gracefully. Pull Request resolved: #24533 Differential Revision: D15062824 Pulled By: cpojer fbshipit-source-id: 80805a47494f0d924b7ee029ce8ca0504eaeee57
1 parent de12b98 commit 954f715

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java

+11
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,17 @@ protected void doInBackgroundGuarded(Void... params) {
182182
} catch (IllegalArgumentException ex) {
183183
// https://bugs.chromium.org/p/chromium/issues/detail?id=559720
184184
return null;
185+
} catch (Exception exception) {
186+
String message = exception.getMessage();
187+
// We cannot catch MissingWebViewPackageException as it is in a private / system API
188+
// class. This validates the exception's message to ensure we are only handling this
189+
// specific exception.
190+
// https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/webkit/WebViewFactory.java#98
191+
if (message != null && message.contains("No WebView installed")) {
192+
return null;
193+
} else {
194+
throw exception;
195+
}
185196
}
186197

187198
if (USES_LEGACY_STORE) {

0 commit comments

Comments
 (0)