依赖org.apache.httpcomponents:httpclient:4.4.1因发布而被忽略,因为它可能与Android提供的内部版本冲突

Sau*_*abh 12 android android-studio

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

警告:依赖org.apache.httpcomponents:httpclient:4.4.1因调试而被忽略,因为它可能与Android提供的内部版本冲突.

警告:依赖org.apache.httpcomponents:httpclient:4.4.1因调试而被忽略,因为它可能与Android提供的内部版本冲突.

我的依赖关系看起来像这样

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'}
Run Code Online (Sandbox Code Playgroud)

正如在其他地方所建议的那样,我将它添加到我的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'}
Run Code Online (Sandbox Code Playgroud)

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

Ali*_*waz 11

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

然后在他们的位置添加 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'
Run Code Online (Sandbox Code Playgroud)

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


Ser*_*kyi 8

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

dependencies {
    compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
}
Run Code Online (Sandbox Code Playgroud)

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


Bah*_*ahu 8

解决方案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'
}
Run Code Online (Sandbox Code Playgroud)

然后我得到了警告就像问题之后,我评论了一些像波纹管的线

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'
}
Run Code Online (Sandbox Code Playgroud)

现在一切正常

编辑

解决方案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"
    }
        ......
}
Run Code Online (Sandbox Code Playgroud)