当前位置:首页 > Cleartext HTTP traffic to xxx not permitted

Cleartext HTTP traffic to xxx not permitted

点击次数:7547  更新日期:2018-09-05

android请求http时报错:Cleartext HTTP traffic to xxx not permitted

原因是Android P的系统上面默认所有Http的请求都被阻止了。

解决方法

在androidmanifest.xml的 application标签上加入 android:usesCleartextTraffic="true"


如下所示


<application
   android:allowBackup="true"
   android:icon="@mipmap/ic_launcher"
   android:label="@string/app_name"
   android:roundIcon="@mipmap/ic_launcher_round"
   android:supportsRtl="true"
   android:usesCleartextTraffic="true"
   android:theme="@style/AppTheme">