WebView在Android 5.0上引发InflateException [英] WebView throws InflateException on android 5.0

查看:371
本文介绍了WebView在Android 5.0上引发InflateException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到"androidx.appcompat:appcompat:1.0.2""com.google.android.material:material:1.1.0-beta01"后,WebView在装有Android 5.0的设备上崩溃并抛出此异常android.view.InflateException

After upgrading to "androidx.appcompat:appcompat:1.0.2" and "com.google.android.material:material:1.1.0-beta01" the WebView crashes on devices with Android 5.0 and throws this exeption android.view.InflateException

原因:android.view.InflateException:二进制XML文件第9行:膨胀类android.webkit.WebView的错误

Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.webkit.WebView

我该如何解决?

推荐答案

此处所述,此问题是由于此修订.它会影响Webview版本低于50的Lollipop设备.使用以下代码作为解决方案.

As explained here, this issue is due to the this revision. It affects Lollipop devices with webview version<50. Use the following code as a solution.

override fun applyOverrideConfiguration(overrideConfiguration: Configuration?) {
        if (Build.VERSION.SDK_INT in 21..25 && (resources.configuration.uiMode == AppConstants.appContext.resources.configuration.uiMode)) {
                return
        }
        super.applyOverrideConfiguration(overrideConfiguration)
}

这篇关于WebView在Android 5.0上引发InflateException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆