-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent MissingWebViewPackageException #119
Conversation
private CookieSyncManager mCookieSyncManager; | ||
|
||
CookieManagerModule(ReactApplicationContext context) { | ||
super(context); | ||
this.mCookieSyncManager = CookieSyncManager.createInstance(context); | ||
this.mCookieManager = CookieManager.getInstance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lazy get CookieManager
instance - basically try to only crash when actually using the library
cookieManager.setAcceptCookie(true); | ||
return cookieManager; | ||
} catch (Exception e) { | ||
throw new Exception(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it explicit that CookieManager.getInstance
can throw
cc @safaiyeh 🙇 |
@capezzbr appreciate the PR! Let's get this deployed. |
## [6.0.8](v6.0.7...v6.0.8) (2021-06-11) ### Bug Fixes * **Android:** Prevent MissingWebViewPackageException ([#119](#119)) ([645f218](645f218))
🎉 This PR is included in version 6.0.8 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What does this PR do
When
com.google.android.webview
is not found by the OS,Fatal Exception: android.util.AndroidRuntimeException: android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed
is throw crashing the app.This PR prevents
@react-native-cookies/cookies
from throwing such exception, preventing the app from crashingHow to reproduce the crash
How does the PR work
This PR postpone accessing the
CookieManager
instance (which could throwMissingWebViewPackageException
) until when it's necessary, instead of doing when the native module is initialized.