警告:依赖org.apache.httpcomponents:httpclient:4.0.1被忽略

时间:2016-03-23 04:34:44

标签: java android dependencies

当我尝试将 libs2 文件夹中的任何.jar文件添加到 libs 文件夹时 enter image description here

我收到以下错误:

    Information:Gradle tasks [:app:assembleDebug]
    Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
             In case of problem, please repackage it with jarjar to change the class packages
    Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android.
             In case of problem, please repackage it with jarjar to change the class packages
    :app:preBuild UP-TO-DATE
   .....
    :app:compileDebugNdk UP-TO-DATE
    :app:compileDebugSources
    :app:transformClassesWithDexForDebug
    UNEXPECTED TOP-LEVEL EXCEPTION:
    Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
    > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 2

我知道 libs2 中的文件导致错误,因为我会逐个添加它们,看看哪些会导致问题,基于这些人{{3} }。

我正在关注需要所有这些.jar文件的suggestion,因此我不明白为什么我会因为必要而收到这些错误。

2 个答案:

答案 0 :(得分:3)

Gradle无需降级或找到另一个jar - 因为每个组/模块可以过滤:

compile ('com.google.http-client:google-http-client-jackson2:1.21.0') {
    exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}

答案 1 :(得分:1)

在5.0及以上(api 23+)http客户端被删除adn甚至不存在降级你的maxsdk或使用url连接 在您的情况下,您应该找到与api23 +

兼容的最新jar文件