1. 程式人生 > >異常A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same

異常A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same

在建立webview的另外一個地方呼叫webview載入網頁,出現異常:

11-10 13:40:49.793: W/WebView(3684): java.lang.Throwable: A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {52837448} called on Looper (JavaBridge, tid 250) {5289c660}, FYI main Looper is Looper (main, tid 1) {52837448})
11-10 13:40:49.793: W/WebView(3684): 	at android.webkit.WebView.checkThread(WebView.java:2072)
11-10 13:40:49.793: W/WebView(3684): 	at android.webkit.WebView.loadUrl(WebView.java:803)
11-10 13:40:49.793: W/WebView(3684): 	at com.leiting.sdk.channel.leiting.object.BaseObject.reload(BaseObject.java:251)
11-10 13:40:49.793: W/WebView(3684): 	at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
11-10 13:40:49.793: W/WebView(3684): 	at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:24)
11-10 13:40:49.793: W/WebView(3684): 	at android.os.Handler.dispatchMessage(Handler.java:102)
11-10 13:40:49.793: W/WebView(3684): 	at android.os.Looper.loop(Looper.java:136)
11-10 13:40:49.793: W/WebView(3684): 	at android.os.HandlerThread.run(HandlerThread.java:61)
11-10 13:40:51.377: W/System.err(3684): java.lang.RuntimeException: java.lang.Throwable: A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {52837448} called on Looper (JavaBridge, tid 250) {5289c660}, FYI main Looper is Looper (main, tid 1) {52837448})
11-10 13:40:51.381: W/System.err(3684): 	at android.webkit.WebView.checkThread(WebView.java:2082)
11-10 13:40:51.381: W/System.err(3684): 	at android.webkit.WebView.loadUrl(WebView.java:803)
11-10 13:40:51.381: W/System.err(3684): 	at com.leiting.sdk.channel.leiting.object.BaseObject.reload(BaseObject.java:251)
11-10 13:40:51.381: W/System.err(3684): 	at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
11-10 13:40:51.381: W/System.err(3684): 	at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:24)
11-10 13:40:51.381: W/System.err(3684): 	at android.os.Handler.dispatchMessage(Handler.java:102)
11-10 13:40:51.385: W/System.err(3684): 	at android.os.Looper.loop(Looper.java:136)
11-10 13:40:51.385: W/System.err(3684): 	at android.os.HandlerThread.run(HandlerThread.java:61)
11-10 13:40:51.385: W/System.err(3684): Caused by: java.lang.Throwable: A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {52837448} called on Looper (JavaBridge, tid 250) {5289c660}, FYI main Looper is Looper (main, tid 1) {52837448})
11-10 13:40:51.385: W/System.err(3684): 	at android.webkit.WebView.checkThread(WebView.java:2072)
11-10 13:40:51.385: W/System.err(3684): 	... 7 more
11-10 13:40:51.393: D/com.leiting.sdk(3684): mWebView WebChromeClientUncaught Error: Error calling method on NPObject.
11-10 13:40:51.393: I/chromium(3684): [INFO:CONSOLE(43)] "Uncaught Error: Error calling method on NPObject.", source: file:///android_asset/html/error.html (43)

分析:根據log日誌可以看到是兩個使用webview的地方不在同一個執行緒。

解決方案:

在另外的一個執行緒中使用webview的方法如下:

                view.post(new Runnable() {
			@Override
			public void run() {
				view.loadUrl(reloadUrl);
			}
		});


相關推薦

異常A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same

在建立webview的另外一個地方呼叫webview載入網頁,出現異常: 11-10 13:40:49.793: W/WebView(3684): java.lang.Throwable: A WebView method was called on thread 'Ja

【Android】java.lang.RuntimeException: java.lang.Throwable: A WebView method was called on thread 'JavaBridge'.

ole lang exp blog web ref overflow post exce 一、問題 Java調用JS事件出現 java.lang.RuntimeException: java.lang.Throwable: A WebView method was call

1 TypeError: Index(...) must be called with a collection of some kind, ' ' was passed columns

今天犯了這個錯誤 ,查到的解決方法如下 columns : Index or array-like Column labels to use for resulting frame. Will default to np.arange(n) if no column labels

安卓開發異常rx.exceptions.OnErrorNotImplementedException: Must be called from main thread of fragment host

rx.exceptions.OnErrorNotImplementedException: Must be called from main thread of fragment host 異常提示:

If ngModel is used within a form tag, either the name attribute must be set or the form contro

背景:angular中使用form表單時報錯。 報錯資訊:If ngModel is used within a form tag, either the name attribute must be set or the form control must b

ValueError: tf.enable_eager_execution must be called at program startup.

在Juptynotebook裡面執行一下程式碼,出現了這個錯誤: import tensorflow as tf tf.enable_eager_execution() tfe = tf.contri

Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding cont

這個Android執行時異常,要求requestWindowFeature方法必須在setContentView載入佈局之前呼叫。 導致錯誤的方法呼叫順序: public void onCreate(Bundle savedInstanceState) {

a different object with the same identifier value was already associated with the session異常

錯誤資訊:a different object with the same identifier value was already associated with the session...... 字面意思:在session中存在識別符號(identifier)相同,物件卻不止一個的情況報出

如何解決The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method

The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method的問題在於:handlerA和handlerB兩個方法有可能同時執行,當A或者B方法遍歷到某一個sessio

Ask HN: To those who spent big bucks on a luxury car: Was it worth it?

We're in the Bay Area (for work) and drive a 12 year old hybrid car. Will be moving out of US in a couple of years. We're on the fence about spending arou

Gson解析json時出現Expected a string but was BEGIN_ARRAY異常,由此發現Gson和FastJson區別

結果:[{"catalog":"環境搭建","article":[{"read":1,"column":9,"id":2,"title":"IntelliJIDEA環境搭建","slug":"static/kotlin_article/0_1.html"},{"read":1,"column":9,"id":

異常:Can't create handler inside thread that has not called Looper.prepare()解決辦法

近些日。cocos2dx遊戲專案要接入一個不主流的支付,達到遊戲內跳轉微信充值,在按照某支付文件寫示例demo的時候各種成功,然而蛋疼的就是移植到遊戲內的時候出現問題。異常就是標題Can't create handler inside thread that has not

Couldn't find a destroy method named 'close' on bean with name 'dataSourceFund'

<bean id="dataSourceFund" class="org.springframework.jdbc.datasource.DriverManagerDataSource"

cvc-complex-type.2.4.a: Invalid content was found starting with element

lex -s 2.4 logs nbsp onf -type sch xsd cvc-complex-type.2.4.a: Invalid content was found starting with element ‘display-name‘. One of ‘{

a different object with the same identifier value was already associated with the session

user exc factory cti lec execute with sta 兩個 錯誤提示: org.springframework.dao.DuplicateKeyException: a different object with the same identi

web.xml 中async-supported爆紅叉叉 cvc-complex-type.2.4.a: Invalid content was found starting with element 'async-supported'.

class 表頭 start lex .org nco app lns pri 新建一個項目在web.xml中些東西是發現async-supported報紅叉 cvc-complex-type.2.4.a: Invalid content was found starti

TypeError: Cannot create a consistent method resolution order (MRO) for bases P1, P2

typeerror: cannot create a consistent method resolution order (mro) for bases p1 p2 新式類多重繼承原則:廣度優先,從左到右 ==================正確================== In [19]:

retrofit請求報錯:Expected a string but was BEGIN_OBJECT at line 1 column 2 path $

Expected a string but was BEGIN_OBJECT at line 1 column 2 path $ 這樣的錯,意思就是我想幫你解析成String而你返回的資料是一個物件,解析不了 需要把返回的物件String 給成JsonObject就可以了 如:C

hibernate的報錯資訊a different object with the same identifier value was already associated with the session解決辦法

廢話不多說,直接說原因,這是在hibernate中,有2個相同型別的實體類具有同樣的主鍵識別符號,然後呼叫update或者呼叫saveOrUpdate,我朋友出這個錯的由於他想要update一條資料時,獲取主鍵時從資料庫查詢獲取,此時接收的物件的主鍵id是12,吧這個值賦給要更新入參的物件,2個物件的主鍵就都

Hibernate經典異常:org.hibernate.NonUniqueObjectException: a different object with the same identifier

最近在用Hibernate做資料修改和刪除的時候,遇到一個Hibernate的經典異常之一: 看了將近兩天的各種部落格、論壇,花費了大量的精力嘗試了 session.evict()、session.clear()、session.merge()等部落格、論壇上的數種方法以及自己的各