Search code examples
androidandroid-webview

WebView only works on emulator and not on device


I have a WebView witch renders an HTML string, it works fine on emulator, but not on real devices.

    fun WebView.loadData(content: String,
                         textColor: String = "black",
                         backgroundColor: String = "white",
                         mimeType: String = "text/html",
                         encoding: String = "utf-8") {
        this.loadData(getHtmlLayout(content, textColor, backgroundColor), mimeType, encoding)
    }


    webViewFragment.settings.javaScriptEnabled = true
    webViewFragment.loadData(content)

looking at stack-trace, there is some message that I'm not sure is related:

I/chromium: [INFO:CONSOLE(0)] "Using unescaped '#' characters in a data URI body is deprecated and will be removed in M71, around December 2018. Please use '%23' instead. See https://www.chromestatus.com/features/5656049583390720 for more details.", source:  (0)

Solution

  • weird, looks like the browsers does not support '#' anymore, in my HTML content I had a HEX color #dd5f11 witch caused this problem, after removing to literal color like red, it fixed.

    https://www.chromestatus.com/features/5656049583390720