react-native打包后安卓9以上http失效
原因:安卓9以上默认禁止不安全请求(包括http请求)
解决方法:
一、使用https
二、开启android:networkSecurityConfig
在下图res目录下新建xml-network_security_config.xml(默认没有)
添加以下代码:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>

在打开main下的AndroidManifest.xml,添加引入配置
android:networkSecurityConfig="@xml/network_security_config"

重新打包即可
26条评论
zorivareworilon
I like what you guys are up also. Such clever work and reporting! Keep up the excellent works guys I have incorporated you guys to my blogroll. I think it’ll improve the value of my web site 🙂