AsyncHttpClient 的使用问题 Header 报错

版权声明:转发请标注原文地址 https://blog.csdn.net/hyt941026/article/details/82346104

GitHub:https://github.com/scruffyfox/AsyncHttpClient

AsyncHttpClient 的版本在1.4.9及以上的版本移除了 httpclient ,所以在使用时会报cz.msebera.android.httpclient.Header[] 找不到的错误,主要是因为cz.msebera.android.httpclient没导入
解决方法:
在项目的buildgradle文件中添加

compile 'cz.msebera.android:httpclient:4.3.6'

添加之后重新build就可以了
但是有可能会出现下面的错误警告

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

只需将上面的compile修改为implementation即可。

其他解决方法:
网上现在cz.msebera.android.httpclient的jar包,导入项目即可
http://mvnrepository.com/artifact/cz.msebera.android/httpclient
该链接有多个版本可供选择

猜你喜欢

转载自blog.csdn.net/hyt941026/article/details/82346104