由于httpcomponents:httpclient冲突警告,APK的生成失败

时间:2016-11-30 08:51:35

标签: android android-studio android-gradle build.gradle

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

**Build.gradle**:-
apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    lintOptions {
        // set to true to turn off analysis progress reporting by lint
        quiet true
        // if true, stop the gradle build if errors are found
        abortOnError false
        // if true, only report errors
        ignoreWarnings true
    }

    defaultConfig {
        applicationId "com.org.mobility"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 4
        versionName "1.6.1"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        repositories {
            maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
            mavenCentral()
        }
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'
    compile 'com.android.support:support-v4:24.0.0'

    compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.1'

}

感谢任何帮助。 提前谢谢。

4 个答案:

答案 0 :(得分:0)

请确保您已在应用程序gradle文件中导入此内容

android {
..
    useLibrary 'org.apache.http.legacy'
..
}

答案 1 :(得分:0)

以下是解决方案,您必须编辑以下代码

android {
    .....
    useLibrary 'org.apache.http.legacy'

 packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
  }
}

在android标签内添加以上代码。希望这会对你有所帮助。

答案 2 :(得分:0)

在您的gradle中添加此项以排除冲突

compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.1' {
exclude module: 'httpclient' 
exclude group: 'org.apache.httpcomponents' 
exclude group: 'org.apache.httpcomponents', module: 'httpclient'

}

答案 3 :(得分:0)

尝试在build.gradle中排除httpclient。将以下代码粘贴到构建,gradle和rebuild中。警告应该消失。

configurations {
    compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}

以下是排除httpclient模块后构建的外观 enter image description here