1
  • 一、APP改用https请求

    这种方式需要接口去协调,把请求域名改为https。

    二、targetSdkVersion 降到27以下

    三、在 res 下新增一个 xml 目录,然后创建一个名为:network_security_config.xml 文件(名字自定) ,内容如下,大概意思就是允许开启http请求。

    1. <?xml version="1.0" encoding="utf-8"?>

    2. <!--Android 9.0 https请求适配-->

    3. <network-security-config>

    4. <base-config cleartextTrafficPermitted="true" />

    5. </network-security-config>

    AndroidManifest.xml

    里面的

    application

    标签下配置:android:networkSecurityConfig="@xml/network_security_config"

    1228601492408111104  评论     打赏       123321xx
    • VGSemir  回复 @123321xx
      感谢大佬
      VGSemir 2020-05-15 21:03   回复 1261226217575600128
    • WYY  回复 @123321xx
      感谢感谢解决了!
      WYY 2020-08-12 15:25   回复 1293447475817996288
    • 蚊子  回复 @123321xx
      今天刚开始学习,也遇到这个问题,感谢大佬,感谢大佬!!!
      蚊子 2020-09-16 18:17   回复 1306063467635138560
  • 我昨晚也是这样,后来到stackoverflow上查了很久,发现只要把先程序从手机或者虚拟机卸载,再重新编译运行就可以了,

    1302969105866940416  评论     打赏       RUOQ
    相关问题
    幻影~ · 提问
    2024-04-13 20:13 7 2
    幻影~ · 找工作
    2024-04-07 10:44 12 2
    幻影~ · 问题
    2024-03-31 17:20 7 2
    TONYGFX · AOSP
    2024-03-28 17:11 4 2