This exception raising only in android 5.1 (Samsung galaxy J3 2016)
Log:
Caused by java.lang.UnsupportedOperationException
java.util.Collections$SingletonMap$1$1.remove (Collections.java:355)
java.util.AbstractMap.remove (AbstractMap.java:397)
org.chromium.android_webview.AwContents.loadUrl (AwContents.java:1594)
org.chromium.android_webview.AwContents.loadUrl (AwContents.java:1458)
com.android.webview.chromium.WebViewChromium.loadUrl (WebViewChromium.java:496)
android.webkit.WebView.loadUrl (WebView.java:862)
I don't have this device, I receive a ton of such exceptions from my crashlytics report. My WebView settings is below:
settings.loadWithOverviewMode = true
settings.useWideViewPort = true
@SuppressLint("SetJavaScriptEnabled")
settings.javaScriptEnabled = true
settings.domStorageEnabled = true
webViewClient = WebViewClient()
And I am loading URL with extra headers provided:
val extraHeaders = mapOf("Referer" to "https://my.site.url")
webView.loadUrl(state.url, extraHeaders)
Ok, I found a problem: In source code of AwContents in loadUrl method you can find such block:
interesting thing is
extraHeaders.remove(header)because I'm creating immutable map, this causing throwing UnsupportedOperationException.Made this change: