【问题标题】:Unable to find HTTP client library - Android找不到 HTTP 客户端库 - Android
【发布时间】:2018-01-07 19:42:09
【问题描述】:

我的项目中有多个模块,并在我的项目级别 build.gradle 文件中添加了以下依赖项,以便在整个项目中使用 HTTP 客户端库:

 compile "cz.msebera.android:httpclient:4.4.1.2"

我创建了一个新模块,我想在其中使用上面提到的库。所以这是我在build.gradle 中为该模块所做的:

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0"
    useLibrary 'cz.msebera.android.httpclient'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

我一直在关注this post。在尝试同步项目时,我收到以下错误:

错误:找不到可选库:cz.msebera.android.httpclient

我无法弄清楚这里出了什么问题。请帮我解决一下。

【问题讨论】:

标签: android httpclient


【解决方案1】:

在你的 build.gradle(Module: app) 中使用这个依赖:

dependencies {
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
}

【讨论】:

【解决方案2】:

使用这个 compile group: 'cz.msebera.android', name: 'httpclient', version: '4.4.1.1' 或者您可以直接使用 HERE 中的库并将其粘贴到您的 lib 文件夹中,然后在粘贴后右键单击该库选择 添加为库

【讨论】:

  • 我是这样使用的:编译组:'cz.msebera.android',名称:'httpclient',版本:'4.4.1.2'
  • 您只需下载这个库并将其放入您的 lib 文件夹中
  • 我这样做了,但仍然不推荐使用 DefaultHttpClient。
  • 替换HttpClient处的DefaultHttpClient
  • HttpClient 没有 getCookieStore()。这是我的另一个问题:stackoverflow.com/questions/45420640/…
【解决方案3】:

使用

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

【讨论】:

  • 而不是主模块的 build.gredle 上的 `cz.msebera.android:httpclient:4.4.1.21?
  • @sayreskabir 您需要在模块依赖项中写入。
猜你喜欢
  • 1970-01-01
  • 2011-09-14
  • 2018-03-02
  • 2012-10-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多