Can
Be Better

React Native 安卓9 release打包不能联网

问题描述

除了安卓9以外其他版本都能都联网,debug版本也能够联网,所以问题就出在安卓9release打包问题上了。实际上安卓9以后对于http请求的配置会类似于ios,需要手动配置联网设置

解决方案

在src/main/res中创建xml文件,并创建network_security_config.xml文件

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

在src/main/androidManifest.xml 添加

android:networkSecurityConfig="@xml/network_security_config"

赞(0) 打赏
不开启评论,如有问题疑问请发邮件。[email protected]最长的路 » React Native 安卓9 release打包不能联网
分享到: 更多 (0)