如何解决Android P DownloadManager停止“不允许使用明文HTTP流量到127.0.0.1”?

如何解决Android P DownloadManager停止“不允许使用明文HTTP流量到127.0.0.1”?,第1张

概述我已经定义了一个自定义网络安全配置,并将其包含在我的清单中,建议使用hereRES/XML/network_security_config.xml:<?xmlversion="1.0"encoding="utf-8"?><network-security-config><domain-configcleartextTrafficPermitted="true">&l @H_419_0@我已经定义了一个自定义网络安全配置,并将其包含在我的清单中,建议使用here

@H_419_0@RES / XML / network_security_config.xml:

@H_419_0@

  <?xml version="1.0" enCoding="utf-8"?>  <network-security-config>  <domain-config cleartextTrafficPermitted="true">    <domain includeSubdomains="true">127.0.0.1</domain>    <domain includeSubdomains="true">localhost</domain>  </domain-config>  </network-security-config>
@H_419_0@这是我的AndroID.manifest:

@H_419_0@

    <application androID:icon="@drawable/icon"              androID:allowBackup="false"             androID:usesCleartextTraffic="true"             androID:networkSecurityConfig="@xml/network_security_config"             androID:label="@string/app_name"             androID:theme="@style/Apptheme"             androID:persistent="true" >
@H_419_0@尝试通过http与127.0.0.1进行通信时,即使有这些更改,我也会在logcat中看到这一点:

@H_419_0@

08-09 10:50:34.395 30791  3607 D NetworkSecurityConfig: Using Network Security Config from resource network_security_config deBUGBuild: true08-09 10:50:34.397 30791  3607 D NetworkSecurityConfig: Using Network Security Config from resource network_security_config deBUGBuild: true08-09 10:50:34.401 30791  3607 W DownloadManager: [647] Stop requested with status http_DATA_ERROR: Cleartext http traffic to 127.0.0.1 not permitted08-09 10:50:34.402 30791  3607 D DownloadManager: [647] Finished with status WAITING_TO_RETRY
@H_419_0@编辑:更新(2018年8月21日)在“修复”此问题后,似乎在安装应用程序几个小时后,DownloadManager神秘地停止接受明文http.

@H_419_0@我无法解释发生了什么.如果我重新启动设备,一段时间内工作正常,那么DownloadManager会再次拒绝明文.我把它写成一个AndroID P BUG,我希望得到解决.

@H_419_0@编辑2:更新(2019年1月17日)我的pixel2现在运行androID 9与2019年1月5日的补丁,我不再看到问题(到目前为止).我猜这个问题已经从8月开始在一些补丁中解决了.

解决方法:

@H_419_0@创建XML res / xml / network_security_config.xml

@H_419_0@

<?xml version="1.0" enCoding="utf-8"?><network-security-config>    <base-config cleartextTrafficPermitted="true" /></network-security-config>
@H_419_0@在AndroIDManifest.xml中的标记Application中引用此文件.喜欢:

@H_419_0@

androID:networkSecurityConfig="@xml/network_security_config"
总结

以上是内存溢出为你收集整理的如何解决Android P DownloadManager停止“不允许使用明文HTTP流量到127.0.0.1”?全部内容,希望文章能够帮你解决如何解决Android P DownloadManager停止“不允许使用明文HTTP流量到127.0.0.1”?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1101320.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存