如何使用 gradle 构建文件从 Android 上的 org.apache 正确导入 HttpClient? [英] How do I properly import HttpClient from org.apache on Android using gradle build file?

查看:39
本文介绍了如何使用 gradle 构建文件从 Android 上的 org.apache 正确导入 HttpClient?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行gradle build"时出现此错误

I am seeing this error when I try to run "gradle build"

WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.3 is ignored for the default configuration as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage with jarjar to change the class packages
:prepareFreeDebugDependencies
:compileFreeDebugAidl UP-TO-DATE
:generateFreeDebugBuildConfig UP-TO-DATE
:mergeFreeDebugAssets UP-TO-DATE
:compileFreeDebugRenderscript UP-TO-DATE
:mergeFreeDebugResources UP-TO-DATE
:processFreeDebugManifest UP-TO-DATE
:processFreeDebugResources UP-TO-DATE
:compileFreeDebug
/home/xrdawson/Projects/Foo/Bar/src/main/java/com/Foo/app/PixActivity.java:20: error: package org.apache.http.entity.mime does not exist
import org.apache.http.entity.mime.HttpMultipartMode;
                              ^

我的 build.gradle 的结尾是这样的:

The end of my build.gradle looks like this:

    repositories {
        mavenCentral()
    }

    dependencies { 
        compile fileTree(dir: 'libs', include: '*.jar')
        compile "org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.3"
        compile "com.madgag:markdownj-core:0.4.1"
//      compile "org.apache.httpcomponents:com.springsource.org.apache.httpcomponents.httpclient:4.2.1"
        compile 'org.apache.httpcomponents:httpclient:4.2.3'
        compile "com.google.android:support-v4:r6"
    } 
}

为什么编译过程忽略了HttpClient,然后编译失败?

Why is the compile process ignoring HttpClient, but then failing to compile?

推荐答案

我认为 httpclient 库不包括 mime 部分,那些在 httpmime 中.这是 httpclient 的一个传递依赖项,但由于它被忽略,因此不会被考虑.

I think the httpclient library doesn't include the mime parts, those are in httpmime. This is a transitive dependency of httpclient, but as that is ignored, it won't be taken into account.

尝试添加此依赖项:

compile "org.apache.httpcomponents:httpmime:4.2.3"

这篇关于如何使用 gradle 构建文件从 Android 上的 org.apache 正确导入 HttpClient?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆