Android Pie不支持http请求的解决方案

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wypeng2010/article/details/84650225

如果,你把app的targetSdkVersion设置为了28,那就可能面临着不能访问http接口和网页的问题。因为Android p默认不支持http的连接请求,和ios一样。要解决这个问题,就需要添加一个配置。

异常为(网络请求):

Exception: IOException java.io.IOException: Cleartext HTTP traffic to * not permitted

或者(webview网页请求):

net::ERR_CLEARTEXT_NOT_PERMITTED

解决方案:

在AndroidManifest.xml文件中的application节点中,配置:android:usesCleartextTraffic=“true”

猜你喜欢

转载自blog.csdn.net/wypeng2010/article/details/84650225