美文网首页
react-native 在Android 9.0 上请求fet

react-native 在Android 9.0 上请求fet

作者: 我的昵称好听吗 | 来源:发表于2019-05-25 10:24 被阅读0次

android 9.0 默认禁止访问不安全的请求,比如http,采坑……

解决方法:

+方法一: 使用认证过的https(我用的阿里云免费证书,如果使用https还得配置,所以用了http)
+方法二(两步):

第一步: 在 res 下新增一个 xml 目录,然后创建一个名为:network_security_config.xml 文件

如下图:


image.png
内容如下:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

第二部:

AndroidManifest.xml文件中添加

 android:networkSecurityConfig="@xml/network_security_config"

如下图:


image.png

相关文章

网友评论

      本文标题:react-native 在Android 9.0 上请求fet

      本文链接:https://www.haomeiwen.com/subject/curazqtx.html