我该如何正确地从org.apache在Android上使用摇篮构建文件导入HttpClient的? [英] How do I properly import HttpClient from org.apache on Android using gradle build file?
本文介绍了我该如何正确地从org.apache在Android上使用摇篮构建文件导入HttpClient的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到这个错误,当我尝试运行摇篮打造
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.
你可以添加以下的依赖:
Try adding this dependency:
compile "org.apache.httpcomponents:httpmime:4.2.3"
这篇关于我该如何正确地从org.apache在Android上使用摇篮构建文件导入HttpClient的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文