WebView 仅适用于模拟器,不适用于设备

WebView only works on emulator and not on device

我有一个 WebView 呈现一个 HTML 字符串,它在模拟器上工作正常,但在真实设备上不工作。

    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)

查看堆栈跟踪,有一些消息我不确定是否相关:

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)

奇怪,看起来浏览器不再支持“#”,在我的 HTML 内容中我有一个 HEX 颜色 #dd5f11 导致了这个问题,在删除文字后颜色像 red,已修复。

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