【问题标题】:Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored警告:依赖 org.apache.httpcomponents:httpclient:4.0.1 被忽略
【发布时间】:2016-07-10 06:09:55
【问题描述】:

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

我收到以下错误:

    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 中的文件会导致错误,因为我会根据此人 suggestion 逐个添加它们并查看哪些会导致问题。

我正在关注tutorial,它需要所有这些 .jar 文件,所以我不明白为什么我会收到这些错误,因为它们是必要的。

【问题讨论】:

    标签: java android dependencies


    【解决方案1】:

    在 5.0 及更高版本 (api 23+) 中,http 客户端已被贬低,甚至不存在降级您的 maxsdk 或使用 url 连接 在您的情况下,您应该找到与 api23+ 兼容的最新 jar 文件

    【讨论】:

    • 好的,我会试试看效果如何。
    【解决方案2】:

    使用Gradle 无需降级或查找另一个 jar - 因为可以按组/模块过滤:

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

    【讨论】:

      猜你喜欢
      • 2016-05-25
      • 2017-09-27
      • 2015-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-07
      • 2020-01-18
      • 2017-12-02
      相关资源
      最近更新 更多