Moosphan/Android-Daily-Interview

2019-10-24:谈一谈Android P禁用http对我们开发有什么影响?

MoJieBlog opened this issue · 3 comments

大家1024快乐。

yline commented

遇到过一次,禁用的结果就是导致Http的请求无效了。

我们的现象就是,http的图片展示不出来了。

最直接的解决方案:
1,让后台换链接,也应该要换
2,target 设置在27及以下。

  • APP改用https请求
  • targetSdkVersion 降到27以下
  • res --> add : network_security_config.xml
 <?xml version="1.0" encoding="utf-8"?>
 <network-security-config>
     <base-config cleartextTrafficPermitted="true" />
 </network-security-config>

AndroidManifest.xml--> application :
android:networkSecurityConfig="@xml/network_security_config"

无法访问http的请求