Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在安卓9以上系统里应用使用http通信配置 #109

Open
soapgu opened this issue Feb 18, 2022 · 0 comments
Open

在安卓9以上系统里应用使用http通信配置 #109

soapgu opened this issue Feb 18, 2022 · 0 comments
Labels
problem problem or trouble 安卓 安卓

Comments

@soapgu
Copy link
Owner

soapgu commented Feb 18, 2022

  • 问题

平时我们都是在专用硬件 安卓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,正好和前面的解释相对应

@soapgu soapgu added 安卓 安卓 problem problem or trouble labels Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem problem or trouble 安卓 安卓
Projects
None yet
Development

No branches or pull requests

1 participant