You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
平时我们都是在专用硬件 安卓7.1上开发应用,最近需要开发针对手机的安卓应用了。结果一运行竟然出错,logcat显示日志为
CLEARTEXT communication to XXX.XX.XX.XX not permitted by network security policy。一看是retrofit,http组件的报错。一脸懵逼,以前没碰到过啊
问题
平时我们都是在专用硬件 安卓7.1上开发应用,最近需要开发针对手机的安卓应用了。结果一运行竟然出错,logcat显示日志为
CLEARTEXT communication to XXX.XX.XX.XX not permitted by network security policy。一看是retrofit,http组件的报错。一脸懵逼,以前没碰到过啊
起因
在Android P(API 28)系统的设备上,默认要求使用加密连接
问题解决
StackOverflow的解决方法说得最好
使用了StackOverflow里面最简单的3号方案 在AndroidManifest.xml里面的application的tag里面设置android:usesCleartextTraffic="true"
文档很清楚说了API < 28 默认都是true, API >= 28 默认值都改成false,正好和前面的解释相对应
The text was updated successfully, but these errors were encountered: