AsyncHttpClient 的使用問題 Header 報錯

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
該鏈接有多個版本可供選擇

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章