我正在从Android O中的IntentService
动态创建Webview,并导致以下崩溃:
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:353)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.RuntimeException: Did not yet override the UI thread
at org.chromium.base.ThreadUtils.getUiThreadHandler(ThreadUtils.java:5)
at org.chromium.base.ThreadUtils.runningOnUiThread(ThreadUtils.java:45)
at com.android.webview.chromium.WebViewChromiumFactoryProvider.C(WebViewChromiumFactoryProvider.java:149)
at com.android.webview.chromium.WebViewChromiumFactoryProvider.l(WebViewChromiumFactoryProvider.java:262)
at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:29)
at android.webkit.WebView.<init>(WebView.java:658)
at android.webkit.WebView.<init>(WebView.java:588)
at android.webkit.WebView.<init>(WebView.java:571)
at android.webkit.WebView.<init>(WebView.java:558)
at android.webkit.WebView.<init>(WebView.java:548)
这曾经适用于早期版本的Android。有什么想法吗?
答案 0 :(得分:1)
正如@EJK所提到的,解决方案是在UI线程上运行有问题的代码。我通过从IntentService切换到服务来实现这一目标。