内容简介:Google表示,为保证用户数据和设备的安全,针对下一代 Android 系统(Android P) 的应用程序,将要求默认使用加密连接,这意味着 Android P 将禁止 App 使用所有未加密的连接,因此运行 Android P 系统的安卓设备无论是接收或者发送流量,未来都不能明码传输,需要使用下一代(Transport Layer Security)传输层安全协议,而 Android Nougat 和 Oreo 则不受影响。Android P(API 29)HttpUrlConnection:
Google表示,为保证用户数据和设备的安全,针对下一代 Android 系统(Android P) 的应用程序,将要求默认使用加密连接,这意味着 Android P 将禁止 App 使用所有未加密的连接,因此运行 Android P 系统的安卓设备无论是接收或者发送流量,未来都不能明码传输,需要使用下一代(Transport Layer Security)传输层安全协议,而 Android Nougat 和 Oreo 则不受影响。
Android P(API 29)
HttpUrlConnection:
W/System.err: java.io.IOException: Cleartext HTTP traffic to **** not permitted
Okhttp:
java.net.UnknownServiceException: CLEARTEXT communication ** not permitted by network security policy
解决
方式1:
Manifest.xml总添加 android:usesCleartextTraffic="true"
<application
android:usesCleartextTraffic="true"
>
</application>
方式二:
在res下创建一个 xml
资源文件夹,然后创建一个 network_security_config.xml
<?xml version="1.0" encoding="utf-8"?> <network-security-config> <base-config cleartextTrafficPermitted="true" /> </network-security-config>
然后在manifest.xml添加
<application
android:networkSecurityConfig="@xml/network_security_config">
</application>
以上所述就是小编给大家介绍的《Android api29网络请求报错》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- Python网络请求库Requests,妈妈再也不担心我的网络请求了
- Flutter网络请求
- Android网络请求练习
- Retrofit网络请求源码解析
- 利用 WireShark 深入调试网络请求
- iOS 使用Moya网络请求
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Hit Refresh
Satya Nadella、Greg Shaw / HarperBusiness / 2017-9-26 / USD 20.37
Hit Refresh is about individual change, about the transformation happening inside of Microsoft and the technology that will soon impact all of our lives—the arrival of the most exciting and disruptive......一起来看看 《Hit Refresh》 这本书的介绍吧!