【问题标题】:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for release as it may be conflicting with the internal version provided by Android依赖 org.apache.httpcomponents:httpclient:4.4.1 在发布时会被忽略,因为它可能与 Android 提供的内部版本冲突
【发布时间】:2015-08-25 16:25:52
【问题描述】:

我在我的项目中使用 httpmime 和 httpcore,我收到了这个警告

警告:依赖 org.apache.httpcomponents:httpclient:4.4.1 是 忽略调试,因为它可能与内部版本冲突 由安卓提供。

警告:依赖 org.apache.httpcomponents:httpclient:4.4.1 是 忽略调试,因为它可能与内部版本冲突 由安卓提供。

我的依赖看起来像这样

dependencies {    
    compile files('libs/gson-2.2.2.jar')
    compile files('libs/classes.jar')
    compile files('libs/gcm.jar')
    compile files('libs/splunk-mint-4.2.jar')
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'org.apache.httpcomponents:httpcore:4.4.1'
    compile 'org.apache.httpcomponents:httpmime:4.4.1'}

按照其他地方的建议,我将此添加到我的 build.gradle 文件中

packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'}

知道如何解决这个问题吗?

【问题讨论】:

    标签: android android-studio


    【解决方案1】:

    这对我有用。

    如果您保留了以下内容:-,

    compile 'org.apache.httpcomponents:httpcore:4.4.4'
    compile group: 'org.apache.httpcomponents' , 
    name: 'httpclient-android' , version: '4.3.5.1'
    

    改成这个,

    compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
    

    【讨论】:

      【解决方案2】:

      解决方案: 添加 useLibrary 'org.apache.http.legacy' 配置{ all*.exclude 模块:'httpclient' }

      我想有些人可能需要这个,

      【讨论】:

        【解决方案3】:

        首先删除线条 compile 'org.apache.httpcomponents:httpcore:4.4.1' compile 'org.apache.httpcomponents:httpmime:4.4.1'

        然后在他们的位置添加行 in build.gradle 给出:

        compile ('org.apache.httpcomponents:httpmime:4.3'){
            exclude group: 'org.apache.httpcomponents', module: 'httpclient'
        }
        compile 'org.apache.httpcomponents:httpcore:4.4.1'
        compile 'commons-io:commons-io:1.3.2'
        

        如果您的 compileSdkVersion 最好是 19(在我的情况下),您可以试试这个。希望这能解决问题...

        【讨论】:

          【解决方案4】:

          解决方案 1

          我知道这太晚了,但我在这里发帖是因为接受的答案对我不起作用

          我以前用过

          dependencies {
              compile 'org.apache.httpcomponents:httpclient:4.5'
              compile 'org.apache.httpcomponents:httpmime:4.3.3'
              compile 'org.apache.httpcomponents:httpcore:4.3.2'
              compile files('libs/httpclient-4.2.1.jar')
              compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
          }
          

          然后我收到了类似问题的警告,之后我评论了如下几行

          dependencies {
              compile 'org.apache.httpcomponents:httpclient:4.5'
              compile 'org.apache.httpcomponents:httpmime:4.3.3'
              //compile 'org.apache.httpcomponents:httpcore:4.3.2'
              //compile files('libs/httpclient-4.2.1.jar')
              compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
          }
          

          现在一切正常

          编辑

          解决方案 2

          我得到了比以前最好的过程

          在lib的文件夹中添加httpcore-4.3-beta1.jarhttpmime-4.3.jar,最后添加

          useLibrary 'org.apache.http.legacy' 在你的 graddle 文件(android 内部)中,如下所示

          android {
              compileSdkVersion 24
              buildToolsVersion "24.0.3"
              //For http
              useLibrary 'org.apache.http.legacy'
              defaultConfig {
                  applicationId "com.app.videorotation"
                  minSdkVersion 15
                  targetSdkVersion 24
                  versionCode 1
                  versionName "1.0"
              }
                  ......
          }
          

          【讨论】:

          • 警告:警告:依赖 org.apache.httpcomponents:httpclient:4.5 被忽略以进行调试,因为它可能与 Android 提供的内部版本冲突。警告:警告:依赖 org.apache.httpcomponents:httpclient:4.5 在发布时被忽略,因为它可能与 Android 提供的内部版本冲突....... ......仍然给出这些警告。
          • @King 你在做的时候被注释了以前的 http 相关依赖项?
          【解决方案5】:

          使用适用于android的apache http客户端的重新打包版本

          dependencies {
              compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
          }
          

          https://hc.apache.org/httpcomponents-client-4.3.x/android-port.html

          【讨论】:

          • 如何在 MainActivity 上导入它?我必须使用来自 import org.apache.http 的 NameValuePair
          猜你喜欢
          • 2016-05-20
          • 1970-01-01
          • 2015-07-03
          • 2015-11-22
          • 2015-12-31
          • 1970-01-01
          • 2016-07-10
          • 2015-05-10
          • 2016-05-25
          相关资源
          最近更新 更多