1

在我的webview我加载一个html,它是一个字符串,如下所示:

myWebView.loadData(htmlTemplate, "text/html", "utf-8");

这将显示某个内容,其中有一个按钮。在单击按钮时,应该加载一个 url:

http://10.5.6.13:9090/

但它失败并出现错误net::ERR_CLEARTEXT_NOT_PERMITTED

我已经尝试了所有建议添加的流行建议答案:

android:usesCleartextTraffic="true"

或覆盖networkSecurityConfig

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">10.5.6.13</domain>
    </domain-config>
</network-security-config>

这是已经尝试过的答案的列表:

https://stackoverflow.com/a/52708032/12202026

https://stackoverflow.com/a/53387018/12202026

http://android--kotlin.blogspot.com/2019/03/android-webview-neterrcleartextnotpermi.html

还有许多流行的其他答案,但仍然没有。

4

0 回答 0