安卓 9 : Cleartext HTTP traffic not permitted in webview

标签 android http flutter webview android-manifest

我正在使用 webview_flutter 插件加载本地主机上托管的页面(使用 dart 创建的服务器,在手机上)但我得到 net::ERR_CLEARTEXT_NOT_PERMITTED 并且我可以'使服务器成为 HTTPS。

我已经实现了所有解决方案 here但这些都不起作用:

  • 添加 network_security_config.xml 文件
  • 添加 android:usesCleartextTraffic 选项

还有其他解决办法吗?

最佳答案

我是安卓开发者,我来告诉你吧。

打开android list 文件(调试和发布),并添加

android:usesCleartextTraffic="true"

application标签

<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="..."
    android:icon="@mipmap/ic_launcher"
    android:usesCleartextTraffic="true">

发布文件路径android/app/src/main/AndroidManifest.xml 调试文件路径 android/app/src/debug/AndroidManifest.xml

enter image description here

enter image description here

关于安卓 9 : Cleartext HTTP traffic not permitted in webview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57040443/

相关文章:

android - Retrofit + GET 方法 + Android 中的 www-form-urlencoded

java - 为什么在 REST API 中为应用程序(android 端)使用身份验证 token 而不是 session_id

flutter - 如何给bottomNavigationBar添加渐变?

flutter - 底部溢出 112 像素的 RenderFlex

authentication - flutter : How to keep user logged in and make logout

android - android中监听器和接口(interface)的区别?

Android 软键盘在全屏时隐藏来自 CordovaWebView 的输入

java - 关于 REST PUT 动词和其他非基于 CRUD 的操作的一些说明

OutputStream 上的 Java 自动 HTTP header

HTTP:通用用户代理指南: header ?