android Failed to load WebView provider: No WebView installed
Asked Answered
I

9

51

Recently, we've started seeing this new entry in our crashlytics which says that android can't find the webview package on the device.

Here's the full stacktrace (classes from our source code have been replaced with ..... :

 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)

We are seeing this on :

Android versions : 5,6,7

Devices Manufacturers: Lenovo, oneplus, samsung, motorola

And, the devices are not rooted.

After searching for a while, I am not able to find any appropriate cause (and handling) for this. Went through this question also but it doesn't have any solution.

Please help.

Edit : This is happening for a lot of our users, so I can't go and tell everyone to check/install webiew from the play store. Is there a better solution for this?

Interlunar answered 5/9, 2017 at 7:8 Comment(5)
The webview isn't installed. Install it from Google Play (link)Cystectomy
Doesn't it come by default ? at least in stock android?Interlunar
yeah, but I am not converned only about my device. This crash is happening on a lot of devices of our users and its pain to go and ask each one of them that they should install the webview. I think there ought to be a better solution for this.Interlunar
I am seeing the same issue for one of my Cordova app. I have no idea how to reproduce that issue because I do not have those devices that my app users havAdjectival
This issue according to my crashlytics is not restricted to any device group or os group, happening for anyoneDownes
I
42

I figured out a probable problem here. As we know that webview has been shipping as a separate app from android 5.0, it may be the case that at the time my view is being inflated, the webview package is being updated by the os and therefore it can't find the webview pacakge for those few moments. I know it's a very borderline case but

  • as I can see, the crash is happening on only >= 5.0 devices which support this hypothesis
  • it's very hard to believe that all such devices don't have webview installed. As a matter of fact, I tried uninstalling the system and chrome packages from my device but still the app doesn't crash.

So here's what I did (hacky solution but prevents crashes):

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
        }
    }

Basically nothing but handling that exception. No rocket science there.

Interlunar answered 17/9, 2017 at 16:14 Comment(9)
The reason makes sense but I am still surprised Android would have such issue. Thanks.Derwin
yeah, agree with that !Interlunar
for my case which using EmojiTextView, the app even not go in catch part and crashes!Milurd
In my case issue happens on "setContentVIew" on onCreate(), what should I do @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.weblayout); //View initializations below }Deformation
I agree with Author and Shyam Sunder. If your layout has a TextView with parameter android:autoLink="all" ("web", etc.) and text contains some kind of hiperlink, you'll see a crash during inflating the View with exception like: caused by android.util.AndroidRuntimeException: android.content.pm.PackageManager$NameNotFoundException: com.google.android.webview. Still happensVallejo
My message contains "WebView" not the lowercase "webview"Glantz
if we are using a open source library what is an example of "the inflating code thats causing the crash" would it be where the webview is being intitalized ?Carbajal
will it crash just from being declared as a class object above onCreate() or only once were actually using it ?Carbajal
Is there a way to reproduce this crash in Android emulator?Adjectival
L
4

I faced the same issue in Android 12. I opened the Android System Webiew in my Play Store app and uninstalled it. After it was uninstalled I enabled it by clicking on the Enable button. That worked for me. As pointed out in the comments, this solution is not valid for issue faced by users in production. I faced this during development in a recently updated device.

Lynn answered 5/7, 2021 at 9:11 Comment(2)
THANK YOU! I've had this issue with Android 12 since the first beta and this finally solved the crash on launch of my app, which used react-native-webview. 🍻Ean
But how will you do that in User's device?Adjectival
D
2

Please refer to this issue.

Workaround

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);
}
Dosimeter answered 18/4, 2018 at 14:44 Comment(0)
M
1

Try to replace

this.autoLinkMask = Linkify.ALL

which is deprecated with

this.autoLinkMask = Linkify.WEB_URLS or Linkify.EMAIL_ADDRESSES or Linkify.PHONE_NUMBERS
Morette answered 9/4 at 10:6 Comment(0)
G
0

My exception is

android.webkit.WebViewFactory$MissingWebViewPackageException

Failed to load WebView provider: No WebView installed

detail stack is:

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)

solution is

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;
            }
        }
    }
}
Gentilis answered 21/4, 2019 at 10:39 Comment(3)
Why are you handling this in a setOverScrollMode() method?Pentagrid
It is not working on my sideAmalbergas
This doesn't solve the source of the exception; you're just swallowing the exception and preventing your app from crashing. Your webview code will still not work as expected, and this shouldn't be treated as a solution to the original problem.Sapling
J
0

According to the TextView's sourceCode

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

The textview with android:autoLink property will call Linkify.addLinks (reaches the method of WebView finally) and cause the crash.

So, we can remove the android:autoLink property and realize with other way to fix the problem.

Jackscrew answered 25/4, 2019 at 3:28 Comment(1)
It's better to put the solution here as an answer instead of an external link. That would make this a better answer. External links may break which could make this one a low quality answer.Xenos
G
0

In My case, I run my app on Android 8.0 Simulator, the exception is:

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

And I google android system webview for android 8, and download Android System Webiew apk from https://www.apkmirror.com/apk/google-inc/android-system-webview/android-system-webview-85-0-4183-101-release/

After adb install com.google.android.webview_85.0.4183.101-418310153_minAPI21\(arm64-v8a,armeabi-v7a\)\(nodpi\)_apkmirror.com.apk

problem was solved

Gourmand answered 9/10, 2023 at 9:19 Comment(2)
Which "simulator" are you using?Raguelragweed
@Raguelragweed Genymotion genymotion.com/downloadGourmand
C
0

Had the same exception thrown in Crashlytics. Answer when inflating XML was not working for me because of view binding and it still crashed. So I moved the try/catch to my first activity (splash) and inside onCreate() I put this:

try {
    new WebView(this);
}
catch (AndroidRuntimeException e) {
    String msg = e.getMessage();
    if (msg != null && msg.contains("No WebView installed")) {
        Toast.makeText(this, "Please install or enable WebView in settings.", Toast.LENGTH_LONG).show();
        finishAffinity();
    }
}
Calliecalligraphy answered 6/2 at 13:59 Comment(0)
R
0

According to Linkify.addLinks source code, WebView class is accessed in gatherMapLinks method that invoked if autoLink is set to map or all (that includes map). If you don't need physical addresses linking substitute all with concrete cases: web, email, etc.

if ((mask & MAP_ADDRESSES) != 0) {
     gatherMapLinks(links, text);
}
Ruthi answered 2/6 at 5:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.