【问题标题】:android studio use cleartext http on api 17android studio 在 api 17 上使用明文 http
【发布时间】:2020-09-27 07:16:39
【问题描述】:

我在localhost 上使用xammp 服务器为php,我在更新之前工作(我认为),但现在http 连接给了我一个例外:

W/System.err: java.io.IOException: 明文 HTTP 流量到 192.168.0.105 不允许

然后我尝试在Application 上为AndroidManifest 添加android:usesCleartextTraffic="true",但也出现下一个错误:

属性 usesCleartextTraffic 仅用于 API 级别 23 及更高级别(当前最小值为 17)

我想继续支持API 17,并且在发布我的应用程序时我将在公共服务器上使用https,我现在该怎么办?

【问题讨论】:

  • 这不是错误,而是警告。
  • 但还是不行

标签: android androidhttpclient


【解决方案1】:

您不必将应用的 minSdkVersion 或 targetSdkVersion 设置为 23 (Android Marshmallow) 即可使用 android:usesCleartextTraffic。在旧平台上,此属性会被忽略,因此无效。

参考 - https://android-developers.googleblog.com/2016/04/protecting-against-unintentional.html?m=1

【讨论】:

    猜你喜欢
    • 2016-04-01
    • 1970-01-01
    • 2022-10-08
    • 2017-02-27
    • 2021-07-18
    • 2013-02-20
    • 2014-05-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多