打包成app,访问外部网页报错:net::ERR_CLEARTEXT_NOT_PERMITTED

作者
2025-06-16阅读 51

1、错误信息

The webpage at http:/10.255.10.150:82/#/Actualsales could not be loaded because:net::ERR_CLEARTEXT_NOT_PERMMITTED

null

2、原因

因为安卓要求访问的网址都是https的,恰巧我的这个不是,因为是测试环境,不可能是专门配置https

3、修改方式(一)

AndroidManifest.xml中添加以下配置

android:usesCleartextTraffic="true"

null

4、修改方式(二)

在xml目录下创建

network_security_config.xml文件,使用以下代码

<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

null

然后AndroidManifest.xml中添加以下配置,引用这个配置

android:networkSecurityConfig="@xml/network_security_config"

null



全部评论

头像
乌兔
前端开发
私信
获得点赞 445
文章被阅读 31,261