本文介绍了Apache HttpClient Android (Gradle)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将此行添加到我的 build.gradle

I have added this line to my build.gradle

compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5'

并且我想在我的代码中使用 MultipartEntityBuilder.但是 Android Studio 不会将库添加到我的代码中.有人能帮我解决这个问题吗?

and I want to use MultipartEntityBuilder in my code. However Android studio doesn't add the library to my code.Can anyone help me with this?

推荐答案

如果您使用目标 SDK 作为 23,请在 build.gradle 中添加以下代码

If you are using target SDK as 23 add the below code in your build.gradle

android{
 useLibrary  'org.apache.http.legacy'
}

此处的附加说明:不要尝试使用这些文件的 gradle 版本.它们坏了 (28.08.15).我尝试了 5 多个小时才能让它工作.它只是没有.不工作:

Additional note here: don't try using the gradle versions of those files. They are broken (28.08.15). I tried over 5 hours to get it to work. It just doesn't.not working:

compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'

另一件事 不要使用:

'org.apache.httpcomponents:httpclient-android:4.3.5.1'

它指的是 21 个 API 级别.

这篇关于Apache HttpClient Android (Gradle)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 05:56
查看更多