【问题标题】:API 19: Cleartext communication not permitted by network security policyAPI 19:网络安全策略不允许明文通信
【发布时间】:2020-12-22 12:04:40
【问题描述】:

我有一个必须在应用程序中使用的公共 API。 API 不提供https,所以我想允许明文访问。

但是我仍然支持 KitKat (API 19)。

因此这个解决方案<application android:networkSecurityConfig="@xml/network_security_config">会导致错误:

Attribute networkSecurityConfig is only used in API level 24 and higher (current min is 19)

那么在这种情况下我该怎么办?

network_security_config

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">http://....com/json/</domain>
    </domain-config>
</network-security-config>

【问题讨论】:

标签: android


【解决方案1】:

您可以设置另一个属性:
android:usesCleartextTraffic="true">

【讨论】:

  • 同样的问题。 Attribute usesCleartextTraffic is only used in API level 23 and higher (current min is 19)
猜你喜欢
  • 1970-01-01
  • 2020-05-01
  • 2020-05-08
  • 2020-05-27
  • 2020-11-23
  • 2020-10-30
  • 1970-01-01
  • 1970-01-01
  • 2016-06-28
相关资源
最近更新 更多