WebView在Android 5.0上引发InflateException [英] WebView throws InflateException on android 5.0
问题描述
升级到"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屋!