【问题标题】:Generation of APK fails due to httpcomponents:httpclient conflict warning由于 httpcomponents:httpclient 冲突警告导致 APK 生成失败
【发布时间】:2016-11-30 08:51:35
【问题描述】:

警告:依赖 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'

}

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

【问题讨论】:

  • 分享你的build.gradle代码
  • @1911192110920:你能在这里为你的应用模块发布你的build.gradle吗?
  • 也许这可以帮助你:stackoverflow.com/questions/30460148/…
  • 不是这个,build.gradle(app) 分享那个文件

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


【解决方案1】:

请确保您已将其导入到您的应用 gradle 文件中

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

【讨论】:

    【解决方案2】:

    这里是解决方案,你必须编辑如下代码

    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 标签内添加上述代码。希望这会对你有所帮助。

    【讨论】:

    • 我也试过了,但没有运气。顺便感谢您的支持。
    • 您面临的实际问题是什么?
    【解决方案3】:

    将此添加到您的 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'
    

    }

    【讨论】:

    • 它显示新警告,如警告:library class android.content.res.XmlResourceParser extends or implements program class org.xmlpull.v1.XmlPullParser。
    • 在 org.gradle 类型的对象上找不到参数 [build_bp7i02jonpi9yt3yo241ty8qf$_run_closure2$_closure10@3f7a69a3] 的方法 com.google.code.ksoap2-android:ksoap2-android:3.6.1()。 api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
    • 此页面可能会有所帮助。 stackoverflow.com/questions/18774355/…
    • 但是想要minifyEnabled应该是真的。
    【解决方案4】:

    尝试在 build.gradle 中排除 httpclient。将下面的代码粘贴到您的构建、gradle 和重建中。警告应该会消失。

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

    这是排除 httpclient 模块后构建的外观

    【讨论】:

      猜你喜欢
      • 2018-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-12
      • 1970-01-01
      • 2017-04-05
      • 2019-03-05
      • 1970-01-01
      相关资源
      最近更新 更多