android无法加载WebView提供程序:未安装WebView

xfb7svmp  于 2023-10-14  发布在  Android
关注(0)|答案(6)|浏览(503)

最近,我们开始在crashlytics中看到这个新条目,它说android在设备上找不到webview包。
下面是完整的stacktrace(源代码中的类已被....替换)。:

Fatal Exception: android.view.InflateException: Binary XML file line #139: Binary XML file line #139: Error inflating class <unknown>

Caused by android.view.InflateException: Binary XML file line #139: Error inflating class <unknown>

Caused by java.lang.reflect.InvocationTargetException
       at java.lang.reflect.Constructor.newInstance0(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
       at android.view.LayoutInflater.createView(LayoutInflater.java:645)
       at g.a.a.a.d.a(SourceFile:211)
       at g.a.a.a.d.a(SourceFile:20)
       at g.a.a.a.d$a.onCreateView(SourceFile:302)
       at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:777)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
       at g.a.a.a.d.inflate(SourceFile:60)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
       at ......(SourceFile:148)
       at ......(SourceFile:119)
       at ......(SourceFile:28)
       at android.support.v4.view.ViewPager.a(SourceFile:1034)
       at android.support.v4.view.ViewPager.a(SourceFile:1182)
       at android.support.v4.view.ViewPager.c(SourceFile:1116)
       at android.support.v4.view.ViewPager.onMeasure(SourceFile:1642)
       at ....(SourceFile:27)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
       at android.view.View.measure(View.java:20234)
       at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1320)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
       at android.widget.ScrollView.onMeasure(ScrollView.java:345)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
       at android.view.View.measure(View.java:20234)
       at android.support.v4.view.ViewPager.onMeasure(SourceFile:1658)
       at android.view.View.measure(View.java:20234)
       at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:825)
       at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:511)
       at android.view.View.measure(View.java:20234)
       at android.support.v4.widget.DrawerLayout.onMeasure(SourceFile:1081)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
       at android.support.v7.widget.ContentFrameLayout.onMeasure(SourceFile:139)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
       at com.android.internal.policy.DecorView.onMeasure(DecorView.java:716)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2659)
       at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1600)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1873)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1485)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7078)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:910)
       at android.view.Choreographer.doCallbacks(Choreographer.java:712)
       at android.view.Choreographer.doFrame(Choreographer.java:646)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:896)
       at android.os.Handler.handleCallback(Handler.java:836)
       at android.os.Handler.dispatchMessage(Handler.java:103)
       at android.os.Looper.loop(Looper.java:203)
       at android.app.ActivityThread.main(ActivityThread.java:6369)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1088)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:949)
Caused by android.util.AndroidRuntimeException: android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed
       at android.webkit.WebViewFactory.getProviderClass(WebViewFactory.java:395)
       at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:194)
       at android.webkit.WebView.getFactory(WebView.java:2592)
       at android.webkit.WebView.findAddress(WebView.java:1958)
       at android.text.util.Linkify.gatherMapLinks(Linkify.java:599)
       at android.text.util.Linkify.addLinks(Linkify.java:287)
       at android.widget.TextView.setText(TextView.java:4474)
       at android.widget.TextView.setText(TextView.java:4395)
       at android.widget.TextView.<init>(TextView.java:1472)
       at android.widget.TextView.<init>(TextView.java:727)
       at android.widget.TextView.<init>(TextView.java:723)
       at me.grantland.widget.AutofitTextView.<init>(SourceFile:25)
       at java.lang.reflect.Constructor.newInstance0(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
       at android.view.LayoutInflater.createView(LayoutInflater.java:645)
       at g.a.a.a.d.a(SourceFile:211)
       at g.a.a.a.d.a(SourceFile:20)
       at g.a.a.a.d$a.onCreateView(SourceFile:302)
       at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:777)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
       at g.a.a.a.d.inflate(SourceFile:60)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
       at ....(SourceFile:148)
       at ....(SourceFile:119)
       at ....(SourceFile:28)
       at android.support.v4.view.ViewPager.a(SourceFile:1034)
       at android.support.v4.view.ViewPager.a(SourceFile:1182)
       at android.support.v4.view.ViewPager.c(SourceFile:1116)
       at android.support.v4.view.ViewPager.onMeasure(SourceFile:1642)
       at ....(SourceFile:27)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
       at android.view.View.measure(View.java:20234)
       at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1320)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
       at android.widget.ScrollView.onMeasure(ScrollView.java:345)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
       at android.view.View.measure(View.java:20234)
       at android.support.v4.view.ViewPager.onMeasure(SourceFile:1658)
       at android.view.View.measure(View.java:20234)
       at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:825)
       at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:511)
       at android.view.View.measure(View.java:20234)
       at android.support.v4.widget.DrawerLayout.onMeasure(SourceFile:1081)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
       at android.support.v7.widget.ContentFrameLayout.onMeasure(SourceFile:139)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
       at com.android.internal.policy.DecorView.onMeasure(DecorView.java:716)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2659)
       at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1600)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1873)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1485)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7078)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:910)
       at android.view.Choreographer.doCallbacks(Choreographer.java:712)
       at android.view.Choreographer.doFrame(Choreographer.java:646)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:896)
       at android.os.Handler.handleCallback(Handler.java:836)
       at android.os.Handler.dispatchMessage(Handler.java:103)
       at android.os.Looper.loop(Looper.java:203)
       at android.app.ActivityThread.main(ActivityThread.java:6369)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1088)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:949)
Caused by android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed
       at android.webkit.WebViewFactory.getWebViewContextAndSetProvider(WebViewFactory.java:294)
       at android.webkit.WebViewFactory.getProviderClass(WebViewFactory.java:354)
       at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:194)
       at android.webkit.WebView.getFactory(WebView.java:2592)
       at android.webkit.WebView.findAddress(WebView.java:1958)
       at android.text.util.Linkify.gatherMapLinks(Linkify.java:599)
       at android.text.util.Linkify.addLinks(Linkify.java:287)
       at android.widget.TextView.setText(TextView.java:4474)
       at android.widget.TextView.setText(TextView.java:4395)
       at android.widget.TextView.<init>(TextView.java:1472)
       at android.widget.TextView.<init>(TextView.java:727)
       at android.widget.TextView.<init>(TextView.java:723)
       at me.grantland.widget.AutofitTextView.<init>(SourceFile:25)
       at java.lang.reflect.Constructor.newInstance0(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
       at android.view.LayoutInflater.createView(LayoutInflater.java:645)
       at g.a.a.a.d.a(SourceFile:211)
       at g.a.a.a.d.a(SourceFile:20)
       at g.a.a.a.d$a.onCreateView(SourceFile:302)
       at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:777)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
       at g.a.a.a.d.inflate(SourceFile:60)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
       at ....(SourceFile:148)
       at ....(SourceFile:119)
       at ....(SourceFile:28)
       at android.support.v4.view.ViewPager.a(SourceFile:1034)
       at android.support.v4.view.ViewPager.a(SourceFile:1182)
       at android.support.v4.view.ViewPager.c(SourceFile:1116)
       at android.support.v4.view.ViewPager.onMeasure(SourceFile:1642)
       at ....(SourceFile:27)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
       at android.view.View.measure(View.java:20234)
       at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1320)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
       at android.widget.ScrollView.onMeasure(ScrollView.java:345)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
       at android.view.View.measure(View.java:20234)
       at android.support.v4.view.ViewPager.onMeasure(SourceFile:1658)
       at android.view.View.measure(View.java:20234)
       at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:825)
       at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:511)
       at android.view.View.measure(View.java:20234)
       at android.support.v4.widget.DrawerLayout.onMeasure(SourceFile:1081)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
       at android.support.v7.widget.ContentFrameLayout.onMeasure(SourceFile:139)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
       at com.android.internal.policy.DecorView.onMeasure(DecorView.java:716)
       at android.view.View.measure(View.java:20234)
       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2659)
       at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1600)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1873)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1485)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7078)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:910)
       at android.view.Choreographer.doCallbacks(Choreographer.java:712)
       at android.view.Choreographer.doFrame(Choreographer.java:646)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:896)
       at android.os.Handler.handleCallback(Handler.java:836)
       at android.os.Handler.dispatchMessage(Handler.java:103)
       at android.os.Looper.loop(Looper.java:203)
       at android.app.ActivityThread.main(ActivityThread.java:6369)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1088)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:949)

我们看到这一点:
Android版本:5,6,7
器械制造商:联想、一加、三星、摩托罗拉
而且,设备没有root。
经过一段时间的寻找,我无法找到任何适当的原因(和处理)。我也问了this问题,但没有任何解决方案。
请帮帮我
编辑:这是发生在我们的很多用户,所以我不能去告诉大家检查/安装webiew从播放商店。有没有更好的解决方案?

rta7y2nd

rta7y2nd1#

我发现了一个可能的问题。正如我们所知,webview已经作为一个独立的应用程序从android5.0,它可能是情况下,在我的看法是膨胀,webview包正在更新的操作系统,因此它不能找到webview包的那几个时刻。我知道这是一个非常边缘的情况下,

  • 正如我所看到的,崩溃只发生在支持这一假设的>= 5.0的设备上
  • 很难相信所有这些设备都没有安装webview。事实上,我试着从我的设备上卸载系统和Chrome软件包,但应用程序仍然没有崩溃。

所以这就是我所做的(黑客解决方案,但防止崩溃):

try {
        // the inflating code that's causing the crash 

    } catch (Exception e) {
        if (e.getMessage() != null && e.getMessage().contains("webview")) {
            // If the system failed to inflate this view because of the WebView (which could
            // be one of several types of exceptions), it likely means that the system WebView
            // is either not present (unlikely) OR in the process of being updated (also unlikely).
            // It's unlikely but we have been receiving a lot of crashes.
            // In this case, show the user a message and finish the activity
        }
    }

基本上什么都没有,只是处理这个异常。没有火箭科学在那里。

ct3nt3jp

ct3nt3jp2#

我在Android 12中遇到了同样的问题。我在我的Play商店应用程序中打开了Android System Webiew并将其删除。在它被删除后,我通过单击启用按钮启用了它。这对我很有效。

hts6caw3

hts6caw33#

请参阅this issue.

解决方法

try {
    super.setText(spannableStringBuilder, type);
} catch (Exception e) {
    // WebView is not installed in some devices by default, Linkify.MAP_ADDRESSES causes the exception
    if (e.getMessage().contains("webview")){
        setAutoLinkMask(Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS);
    }
    super.setText(spannableStringBuilder, type);
}
fsi0uk1n

fsi0uk1n4#

我的例外是

android.webkit.WebViewFactory$MissingWebViewPackageException

Failed to load WebView provider: No WebView installed

详细堆栈是:

java.lang.RuntimeException:Unable to start activity ComponentInfo{cn.trinea.android.developertools/a.a.aa}: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class a.a.ab
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
......
android.webkit.WebViewFactory$MissingWebViewPackageException:Failed to load WebView provider: No WebView installed
android.webkit.WebViewFactory.getWebViewContextAndSetProvider(WebViewFactory.java:270)
android.webkit.WebViewFactory.getProviderClass(WebViewFactory.java:330)
android.webkit.WebViewFactory.getProvider(WebViewFactory.java:194)
android.webkit.WebView.getFactory(WebView.java:2325)
android.webkit.WebView.ensureProviderCreated(WebView.java:2320)
 android.webkit.WebView.setOverScrollMode(WebView.java:2379)
 android.view.View.<init>(View.java:4023)
 android.view.View.<init>(View.java:4146)
 android.view.ViewGroup.<init>(ViewGroup.java:579)
 android.widget.AbsoluteLayout.<init>(AbsoluteLayout.java:55)
 android.webkit.WebView.<init>(WebView.java:627)
 android.webkit.WebView.<init>(WebView.java:572)
 android.webkit.WebView.<init>(WebView.java:555)
 android.webkit.WebView.<init>(WebView.java:542)

溶液

public class MyWebView extends WebView {

    @Override
    public void setOverScrollMode(int mode) {
        try {
            super.setOverScrollMode(mode);
        } catch (Exception e) {
            if (e.getMessage() != null && e.getMessage().contains("Failed to load WebView provider: No WebView installed")) {
                e.printStackTrace();
            } else {
                throw e;
            }
        }
    }
}
disho6za

disho6za5#

根据TextView的sourceCode

if (mAutoLinkMask != 0) {
    ...
    if (Linkify.addLinks(s2, mAutoLinkMask)) {
        ...
    }
}

具有android:autoLink属性的textview将调用Linkify.addLinks(最终到达WebView的方法)并导致崩溃。
因此,我们可以删除android:autoLink属性,并使用其他方法来解决问题。

nvbavucw

nvbavucw6#

在我的例子中,我在Android 8.0模拟器上运行我的应用,例外是:

Chromium WebView package does not exist
                 android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed

我谷歌android system webview for android 8,并从https://www.apkmirror.com/apk/google-inc/android-system-webview/android-system-webview-85-0-4183-101-release/下载Android System Webiew apk
adb install com.google.android.webview_85.0.4183.101-418310153_minAPI21\(arm64-v8a,armeabi-v7a\)\(nodpi\)_apkmirror.com.apk之后
问题解决了

相关问题