I have a couple problems when loading urls on Webview on certain devices: such as emulators in general (Nexus 5, Android API 21) and, real devices (Huawei P30, Android 10).
EDIT: I am using minSDK 19. The urls is a https scheme.
binding.webview.apply {
        settings.javaScriptEnabled = true
        settings.loadWithOverviewMode = true
        settings.domStorageEnabled = true
        settings.databaseEnabled = true
        settings.setRenderPriority(WebSettings.RenderPriority.HIGH)
        settings.cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK
        settings.setAppCacheEnabled(true)
        settings.layoutAlgorithm = WebSettings.LayoutAlgorithm.NARROW_COLUMNS
        settings.useWideViewPort = true
        settings.enableSmoothTransition()
        webViewClient = object : WebViewClient() {
            override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
                writeData(getString(XXX).toString())
                super.onPageStarted(view, url, favicon)
                binding.layoutProgress.progressLayout.show()
            }
            override fun onPageFinished(view: WebView?, url: String?) {
                super.onPageFinished(view, url)
                binding.layoutProgress.progressLayout.invisible()
            }
        }
    }
I am writting stuff on localStorage that need to have the browser via javascript, in order to load. I am not sure if here is the problem...
private fun writeData(value: String) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        binding.webview.evaluateJavascript(
            "localStorage.setItem('$XXX','$value');",
        ) { returnedValue -> Log.d("chromium1", "onReceiveValue: $returnedValue") } //returns null on the devices that does not work or value on the working devices
    } else {
        binding.webview.loadUrl("javascript:localStorage.setItem('$XXX','$value');")
    }
}
The chromium error that appears on devices that did not load is:
"Uncaught SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.",
"Unrecognized Content-Security-Policy directive 'navigate-to'. ", source: url.com (0)
"Unrecognized Content-Security-Policy directive 'navigate-to'.   ", source: url.com (0)
"The key "shrink-to-fit" is not recognized and ignored.", source: url.com (5)
"Refused to load the stylesheet 'https://fonts.googleapis.com/css?family=Source+Code+Pro:300,600&display=swap' because it violates the following Content Security Policy directive: "style-src 'self' 'unsafe-inline' https://widget.freshworks.com blob:". ", source: url.com (11)
"Uncaught SyntaxError: Use of const in strict mode.", source: url.something.js (21)
Thank you very much in advance.
 
     
     
    