java 动态代理 阿bin_Android WebView 的方法只能在 UI 线程中运行

Android WebView的所有操作必须在UI线程中进行,否则可能导致崩溃。错误日志显示在4.3版本的设备上尤为常见,提示警告未来版本可能不再支持非UI线程调用。分析了WebViewCoreThread上的错误,强调遵守UI线程规则的重要性。
摘要由CSDN通过智能技术生成

Android WebView 的方法只能在 UI 线程中运行

Android,WebView,线程

2018.04.25

根据报错信息,Android 的 WebView 所有的方法都只能在 UI 线程中调用,在非 UI 线程调用都会产生一些意外的崩溃。

今天分析收集到的崩溃日志,看到一下的一些日志信息。发生的机型主要集中在 4.3 的机型中。很奇怪在更高的版本中,并没有发现这样的问题。记录一下,以备后续观察。

通过日志可以看出,所有的 WebView 方法都只能在 UI 线程中被调用。

java.lang.RuntimeException: java.lang.Throwable: Warning: A WebView method was called on thread 'WebViewCoreThread'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads.

at android.webkit.WebView.checkThread(WebView.java:2093)

at android.webkit.WebView.loadUrl(WebView.java:836)

at com.binkery.android.utils.webviewbridge.Bridge.executeJavascript(Bridge.java:260)

at com.binkery.android.utils.webviewbridge.Bridge.executeJavascript(Bridge.java:229)

at com.binkery.android.utils.webviewbridge.Bridge.dispatchMessage(Bridge.java:113)

at com.binkery.android.utils.webviewbridge.Bridge.queueMessage(Bridge.java:100)

at com.binkery.android.utils.webviewbridge.Bridge.access$300(Bridge.java:25)

at com.binkery.android.utils.webviewbridge.Bridge$2.callback(Bridge.java:202)

at com.binkery.android.webview.AbsMethod.doResponse(AbsMethod.java:48)

at com.binkery.android.webview.methods.MethodVolunteer.downResponse(MethodVolunteer.java:43)

at com.binkery.my.volunteer.DownQRSaveUtil$1.handleMessage(DownQRSaveUtil.java:35)

at android.os.Handler.dispatchMessage(Handler.java:99)

at android.os.Looper.loop(Looper.java:137)

at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:1092)

at java.lang.Thread.run(Thread.java:841)

Caused by: java.lang.Throwable: Warning: A WebView method was called on thread 'WebViewCoreThread'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads.

at android.webkit.WebView.checkThread(WebView.java:2084)

... 14 more

java.lang.Throwable: Warning: A WebView method was called on thread 'WebViewCoreThread'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads.

at android.webkit.WebView.checkThread(WebView.java:2084)

at android.webkit.WebView.loadUrl(WebView.java:836)

at com.binkery.android.utils.webviewbridge.Bridge.executeJavascript(Bridge.java:260)

at com.binkery.android.utils.webviewbridge.Bridge.executeJavascript(Bridge.java:229)

at com.binkery.android.utils.webviewbridge.Bridge.dispatchMessage(Bridge.java:113)

at com.binkery.android.utils.webviewbridge.Bridge.queueMessage(Bridge.java:100)

at com.binkery.android.utils.webviewbridge.Bridge.access$300(Bridge.java:25)

at com.binkery.android.utils.webviewbridge.Bridge$2.callback(Bridge.java:202)

at com.binkery.android.webview.AbsMethod.doResponse(AbsMethod.java:48)

at com.binkery.android.webview.methods.MethodVolunteer.downResponse(MethodVolunteer.java:43)

at com.binkery..DownQRSaveUtil$1.handleMessage(DownQRSaveUtil.java:35)

at android.os.Handler.dispatchMessage(Handler.java:99)

at android.os.Looper.loop(Looper.java:137)

at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:1092)

at java.lang.Thread.run(Thread.java:841)

相关文章

- EOF -

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处,尊重他人劳动。

转载请注明:文章转载自 Binkery 技术博客 [https://binkery.com]

本文标题: Android WebView 的方法只能在 UI 线程中运行

本文地址:https://binkery.com/archives/112002.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值