Vivo手机 Android 5.1系统适配WebView

报错如下:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rise.parent/com.rise.parent.ui.job.TaskWebEntranceActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class com.rise.widget.RiseWebView
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.rise.widget.RiseWebView
Caused by: java.lang.reflect.InvocationTargetException
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2040002

设置WebView构造器如下即可解决:

@SuppressLint("SetJavaScriptEnabled")
open class RiseWebView@JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0,
    defStyleRes: Int = 0
) : WebView(context.createConfigurationContext(Configuration()), attrs, defStyleAttr, defStyleRes){

参考文章:
java - android.view.InflateException扩展类android.webkit.WebView时出错

你可能感兴趣的:(Vivo手机 Android 5.1系统适配WebView)