9.0 http報錯信息
httpurlconnection
1 cleartext http traffic not permitted
okhttp
2 java.net.UnknownServiceException: CLEARTEXT communication ** not permitted by network security policy
原因:權(quán)限
解決方法
在 res 下新增一個 xml 目錄,然后創(chuàng)建一個名為:network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
AndroidManifest文件下application下增加配置
<application
...
android:networkSecurityConfig="@xml/network_security_config"
...
>
9.0類缺失問題
報錯
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.impl.client.DefaultHttpClient" on path: DexPathList
原因:庫被移除
解決方法
<application
...
>
<uses-library android:name="org.apache.http.legacy" android:required="false" />
</application >