java - Flutter Insecure HTTP is not allowed by platform Error
问题描述
我正在尝试发出一个 http 发布请求,以将用户从在真实设备上运行的颤振应用程序中拯救出来。我在设置了 nginx 的 ubuntu 服务器上运行 Springboot RESTful API。可以发送邮递员请求。我已经尝试android:usesCleartextTraffic="true"
在我的 android 清单中添加到我的应用程序标记,并且我尝试添加一个network_security_config
并将其添加到我的应用程序标记以及应用程序标记内的元数据标记。
这是我的 network_security_config 文件:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
这是我调用 api 的颤振应用程序的代码:
这是我的 Springboot RESTful API 代码:
解决方案
I have figured out my issue! The issue was that I was adding android:usesCleartextTraffic="true" in the wrong android manifest file. Previously I had it under android/app/src/profile/AndroidManifest.xml but the proper spot is under andoird/app/src/debug/AndroidManifest.xml. As stated in https://flutter.dev/docs/release/breaking-changes/network-policy-ios-android
推荐阅读
- angular - 如何在不中断可观察流订阅的情况下向主题发送不同的可观察结果?
- python-3.x - MoviePy - 将音频长度设置为剪辑
- php - 为什么 URL::defaults() 在 Laravel 中不起作用?
- oracle - Oracle HTTP 服务器 Ubuntu 安装
- reactjs - React 组件数组的渲染顺序错误
- java - 使用“like”运算符在自定义 jpa 查询中键入不匹配错误
- sql-server - 如何在 NIFI 中连接 SQL Server 2005
- javascript - 如何在自定义 js 对象上设置自己的处理程序事件?
- python - 如何在 python 中使用 boto3 对象向函数添加类型提示?
- php - 收到错误:此集合实例上不存在属性 [prod_name]