【问题标题】:java.util.zip.ZipException: duplicate entry: org/apache/commons/collections/ArrayStack.classjava.util.zip.ZipException:重复条目:org/apache/commons/collections/ArrayStack.class
【发布时间】:2020-01-04 21:14:41
【问题描述】:

花了将近一天的时间搜索这个问题,但没有运气。这是由于依赖项的冗余。重复的还找不到。

在我的 build.gradle 文件中

apply plugin: 'com.android.application'

android {

defaultConfig {
    applicationId "com.ujjwalmainali.univhub"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 8
    versionName "1.1"
    multiDexEnabled true
    vectorDrawables.useSupportLibrary = true
}

configurations {
    all*.exclude group: 'commons-logging', module: 'commons-logging'

}


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


compileSdkVersion 25
buildToolsVersion '25.0.2'


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

 repositories {
  maven { url "https://raw.githubusercontent.com/smilefam/SendBird-SDK-
Android/master/" }
}

dependencies {
testCompile 'junit:junit:4.12'

//iconify dependencies



compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2' // (v4.5)

compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.sendbird.sdk:sendbird-android-sdk:3.0.25'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile 'net.gotev:uploadservice-okhttp:3.0.3'
compile 'com.jaredrummler:material-spinner:1.1.0'
compile 'com.nononsenseapps:filepicker:4.1.0'
compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.0'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'io.github.kobakei:ratethisapp:1.2.0'
compile 'com.github.paolorotolo:appintro:4.1.0'


//webview
compile 'com.thefinestartist:finestwebview:1.2.7'

//for android drawer
compile('com.mikepenz:materialdrawer:5.8.1@aar') {
    transitive = true
}
compile ('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.10.4@aar'){
    transitive=true
}


compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.3'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.googlecode.json-simple:json-simple:1.1'
compile 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1@aar'
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'commons-validator:commons-validator:1.4.1'
//for the calender date picker supports other type picker also like radial time picker,recurrence picker
compile 'com.code-troopers.betterpickers:library:3.1.0'
compile 'com.mikepenz:actionitembadge:3.3.1@aar'
compile 'com.mobsandgeeks:android-saripaar:2.0.1'
compile 'com.nightonke:boommenu:2.0.9'





compile 'com.google.android.gms:play-services-location:9.2.0'
compile 'com.google.android.gms:play-services-maps:9.2.0'
compile 'com.google.android.gms:play-services-places:9.2.0'

compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:cardview-v7:25.0.0'



//circular progress bar
compile 'com.victor:lib:1.0.4'

//app crash report
compile 'ch.acra:acra:4.9.0'

ext.googlePlayServicesVersion='10.0.1'
ext.supportLibraryVersion='23.1.1'

provided 'org.glassfish:javax.annotation:10.0-b28'

apply plugin: 'com.google.gms.google-services'
}

错误:任务 ':app:transformClassesWithJarMergingForDebug' 执行失败。

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:org/apache/commons/collections/ArrayStack.class

【问题讨论】:

  • 您可能正在使用 Android Studio 对吧?你不能按Ctrl-N搜索ArrayStack类吗,搜索结果会显示所有包含它的库。
  • 如何删除重复的类文件?
  • 删除重复库之一。或者更复杂的解决方案是排除依赖项的依赖项,因此您只删除冲突的部分而不是整体。

标签: java android


【解决方案1】:
compile 'commons-validator:commons-validator:1.4.1'

commons-validator 依赖项包含两个版本的 ArrayStack,因为它对 commons-collections 具有传递性依赖项。

通过在声明中排除 commons-collections,您实际上删除了与该库关联的所有类,并且在运行时只剩下一个 ArrayStack 类。

compile('commons-validator:commons-validator:1.4.1') {
    exclude module: 'commons-collections'
}

【讨论】:

  • 这个方法解决了我的问题。你救了我的好朋友。
  • 很高兴听到。通过接受答案,您将问题标记为已解决,这样以后其他人就不需要尝试回答了。
【解决方案2】:

在我的情况下,以下解决方案对我有用:

刚刚添加到android里面的myProject/app/build.gradle{}

configurations {
        all*.exclude group: 'commons-collections', module: 'commons-collections'
}

然后:同步 -> 清理 -> 重建,项目

【讨论】:

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