My Android Java app shows some HTML content, but not on the initial screen. To make initial app loading faster, the WebView is initialized dynamically when needed:
m_TheEntry = new WebView(Ctxt); //Ctxt is an Activity
m_TheEntry.setTag("Entry");
m_TheEntry.setWebViewClient(new EntryClient());
if(BuildConfig.DEBUG)
m_TheEntry.setWebChromeClient(LoggingChromeClient.The);
m_TheEntry.setLayoutParams(...);
m_TheEntry.getSettings().setJavaScriptEnabled(true);
m_TheEntry.addJavascriptInterface(m_JSHelper = new EntryJSHelper(), "host");
m_TheEntry.getSettings().setBuiltInZoomControls(true);
//m_EntryFrame is a layout object
m_EntryFrame.addView(m_TheEntry);
Most of the time, it works as expected. But I'm getting crash reports that the WebView construction throws various exceptions on user devices. The recent ones report that android.content.res.Resources$NotFoundException: Resource ID #0x40c0008, but some older ones are android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed .
How's that even possible? WebView is an SDK class, shouldn't it be present on all flavors of Android? And how does one sensibly fall back from that?