我该如何正确地从org.apache在Android上使用摇篮构建文件导入HttpClient的?我该、摇篮、正确地、文件

2023-09-04 06:10:55 作者:花美男世界你不懂

我看到这个错误,当我尝试运行摇篮打造

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"