环境
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&gt;(AppWebView.kt:55)
       at com.codeview.skycastle.ui.widget.AppWebView.<init&gt;(AppWebView.kt:17)
       at com.codeview.skycastle.ui.widget.AppWebView.<init&gt;(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)

警告
警告信息应用应用build可以处理警告
在这里插入图片描述

总结
网上相同问题索引很多解决方案也有,但是不同上下文环境解决方式并不通用,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进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注