android - HttpClient 依赖警告 Android Studio

标签 android android-studio gradle httpclient apache-httpclient-4.x

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId "com.example"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    maven { url "https://jitpack.io" }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:support-v13:23.1.0'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
    compile 'oauth.signpost:signpost-core:1.2.1.2'
    compile 'oauth.signpost:signpost-commonshttp4:1.2.1.2'
    compile('org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2')
    compile ('oauth.signpost:signpost-commonshttp4:1.2.1.2') {
        exclude module: 'commons-logging'
        exclude module: 'httpcore'
        exclude module: 'httpclient'
    }
    compile ('oauth.signpost:signpost-core:1.2.1.2') {
        exclude module: 'commons-codec'
        }
}

我收到以下警告

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

不知道如何处理它,任何帮助将不胜感激

最佳答案

一些事情:

compile 'oauth.signpost:signpost-commonshttp4:1.2.1.2'
compile('org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2')
compile ('oauth.signpost:signpost-commonshttp4:1.2.1.2') {
    exclude module: 'commons-logging'
    exclude module: 'httpcore'
    exclude module: 'httpclient'
}

您已添加 oauth.signpost:signpost-commonshttp4:1.2.1.2 两次:一次没有任何排除,一次有。尝试删除那个,看看你的警告是否消失(它们应该消失)。

此外,使用最新的构建工具版本(您可能需要升级到 23.0.2),您可以删除此行:

compile('org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2')

(旁注:这可能应该是provided,而不是compile)。

然后添加到android部分,如illustrated here :

useLibrary 'org.apache.http.legacy'

关于android - HttpClient 依赖警告 Android Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33800564/

相关文章:

java - Android Socket 连接(权限被拒绝)

android - 升级android studio后Executor Singleton未启动

gradle - 如何在 Gradle Kotlin DSL 中使用来自 gradle.properties 的插件版本?

android - 在android中全屏显示webview

android - FrameLayout 无法转换为 android.widget.AbsListView

android - 为android开发安装eclipse ide 3.5

android - 需要帮助修复 Android Studio 中的工具栏问题

java - 我调用 getAction() 函数的 Intent 值从哪里来? (这是BroadcastReceiver类的重写方法)

gradle - 收集 Gradle 项目的依赖约束

android - 添加google-services后出现多个dex错误