【问题标题】:java.util.zip.ZipException: duplicate entry: org/apache/http/HttpMessage.classjava.util.zip.ZipException:重复条目:org/apache/http/HttpMessage.class
【发布时间】:2015-10-24 08:40:11
【问题描述】:

我收到以下错误。最近两天我没有尝试解决它,但没有任何解决问题的方法。 错误:任务 ':app:packageAllDebugClassesForMultiDex' 执行失败。

java.util.zip.ZipException:重复条目:org/apache/http/HttpMessage.class 这是我的 build.gradle(app)

apply plugin: 'com.android.application'


android {
compileSdkVersion 23
buildToolsVersion '23.0.0'

defaultConfig {
    applicationId "com.mycompany.newlogin"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
productFlavors {

}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.guava:guava-jdk5:17.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'

}

请帮我解决这个问题。提前谢谢你。

【问题讨论】:

    标签: android android-multidex


    【解决方案1】:

    我也有这个错误,我通过删除httpcore解决了这个问题

    在您的build.gradle(app) 中删除这些行

    compile 'org.apache.httpcomponents:httpcore:4.4.1'
    compile 'org.apache.httpcomponents:httpclient:4.5'
    

    然后将最新的 apache 库添加到您的 build.gradle(app)

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

    【讨论】:

    • 亲爱的你。排灯节快乐
    【解决方案2】:

    看看你引用的包,org.jbundle.util.osgi.wrapped.org.apache.http.client 似乎至少包含一些 httpcore 类,尤其是你的错误消息中提到的那个。所以我猜你根本不能也不应该将两者都用作依赖项,而只能使用你真正需要的那些。

    【讨论】:

      【解决方案3】:

      以下库导致冲突,我将其从 build.gradle 中删除

        compile 'com.loopj.android:android-async-http:1.4.9'
        compile 'org.apache.httpcomponents:httpcore:4.4.1'
      

      我只留下了:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-01-24
        • 1970-01-01
        • 1970-01-01
        • 2016-12-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多