react-native0.63.2 安卓release包无法连接网络

原因:后台测试环境接口为http开头,Android 限制了明文流量的网络请求,非加密的流量请求都会被系统禁止掉

解决方法:
1、在android/app/src/main/res目录下新建一个xml目录,在xml目录中新建名为network_security_config.xml的 文件,内容如下

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

2、在android/app/src/main目录下的AndroidManifest.xml文件中application标签内声明文件

android:networkSecurityConfig="@xml/network_security_config"	
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐