Android 联网错误:java.io.IOException: Cleartext HTTP traffic to xx.xx.xx.xx(Ip) not permitted 错误

这个问题出现在Android P(Android 9.0)机器及以上的异常

问题原因:由于Google对明文数据传输进行限制,所以在之后的版本都默认不支持http的传输,而是https的传输,所以会报此错误

同样地,如果应用嵌套了webview,webview也只能使用https请求。

解决办法:

若想继续使用http的方式就必须在

AndroidManifest.xml配置文件的<application>标签中直接插入 android:usesCleartextTraffic="true"

如下:
<application    
        ..................................
        android:usesCleartextTraffic="true"
        ..................................
</application>

就可以了。

posted @ 2022-01-20 17:16  一只呆萌的萌呆  阅读(324)  评论(0编辑  收藏  举报