为什么我在升级到 Cordova Android 8 后看到 net::ERR_CLEARTEXT_NOT_PERMITTED 错误? [英] Why am I seeing net::ERR_CLEARTEXT_NOT_PERMITTED errors after upgrading to Cordova Android 8?

查看:38
本文介绍了为什么我在升级到 Cordova Android 8 后看到 net::ERR_CLEARTEXT_NOT_PERMITTED 错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到 Cordova Android 8.0 后,我在尝试连接到 http:// 目标时看到 net::ERR_CLEARTEXT_NOT_PERMITTED 错误.

After upgrading to Cordova Android 8.0, I am seeing net::ERR_CLEARTEXT_NOT_PERMITTED errors when trying to connect to http:// targets.

这是为什么,我该如何解决?

Why is that and how can I resolve this?

推荐答案

Cordova Android 平台中的默认 API 级别已升级.在 Android 9 设备上,明文通信现在默认禁用.

The default API level in the Cordova Android platform has been upgraded. On an Android 9 device, clear text communication is now disabled by default.

要再次允许明文通信,请将 application 标签上的 android:usesCleartextTraffic 设置为 true:

To allow clear text communication again, set the android:usesCleartextTraffic on your application tag to true:

<platform name="android">
  <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
      <application android:usesCleartextTraffic="true" />
  </edit-config>
</platform>

如评论中所述,如果您之前未定义 android XML 命名空间,您将在构建期间收到 error: unbound prefix.这表明您需要将它添加到您的 widget 标签中,在同一个 config.xml 中,如下所示:

As noted in the comments, if you have not defined the android XML namespace previously, you will receive an error: unbound prefix during build. This indicates that you need to add it to your widget tag in the same config.xml, like so:

<widget id="you-app-id" version="1.2.3"
xmlns="http://www.w3.org/ns/widgets" 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cdv="http://cordova.apache.org/ns/1.0">

这篇关于为什么我在升级到 Cordova Android 8 后看到 net::ERR_CLEARTEXT_NOT_PERMITTED 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆