如何使用 gradle 构建文件从 Android 上的 org.apache 正确导入 HttpClient?

编程入门 行业动态 更新时间:2024-10-26 11:19:37
本文介绍了如何使用 gradle 构建文件从 Android 上的 org.apache 正确导入 HttpClient?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

当我尝试运行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.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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-19 15:05:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/963813.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   正确   文件   Android   gradle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!