环境:
Android studio Dolphin 2021.3.1 pathch 1
gradle 7.2
设备 oppo android 7.1.1
现象:
在android 7.x系统设备上。跑内嵌webView界面,调用webViewClient 会报如下异常。
解决:
override fun getWebViewClient(): WebViewClient {
return if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
super.getWebViewClient()
} else {
WebViewClient()
}
}
Caused by java.lang.NoSuchMethodError: No virtual method getWebViewClient()Landroid/webkit/WebViewClient; in class Landroid/webkit/WebView; or its super classes (declaration of 'android.webkit.WebView' appears in /system/framework/framework.jar:classes2.dex)
at com.codeview.skycastle.plugin.web.WebViewExtKt.injectLoadStateView(WebViewExt.kt:19)
at com.codeview.skycastle.plugin.web.WebViewExtKt.injectLoadStateView$default(WebViewExt.kt:13)
at com.codeview.skycastle.ui.widget.AppWebView.<init>(AppWebView.kt:55)
at com.codeview.skycastle.ui.widget.AppWebView.<init>(AppWebView.kt:17)
at com.codeview.skycastle.ui.widget.AppWebView.<init>(AppWebView.kt)
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 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
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.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at com.codeview.skycastle.ui.comm.WebFragment.onCreateView(WebFragment.kt:33)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3104)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:524)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1890)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1808)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1751)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:538)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:186)
at android.app.ActivityThread.main(ActivityThread.java:6513)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:804)
总结:
网上相同问题索引很多,解决方案也有,但是不同上下文环境解决方式并不通用,Android 设备碎片化严重,品牌型号、系统版本等都是不确定因素。未定位具体原因不建议上手改代码。
引用:
1.创建全局WebView报错Didn’t find class “android.webkit.RenderProcessGoneDetail”
2.android-webview-inflateexception-on-android-7-0
原文地址:https://blog.csdn.net/o279642707/article/details/128598533
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_48292.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。