I'm creating a Webview dynamically from an IntentService
in Android O, and getting the following crash:
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)
This used to work fine with earlier versions of Android. Any ideas?
As @EJK mentioned, the solution was to run the problematic code on the UI thread. I achieved that by switching from an IntentService to a Service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With