错误:java.io.IOException:重复的zip条目

时间:2018-03-27 13:53:46

标签: android android-gradle

我试图解决一个问题几天 当我运行我的应用程序时,我收到此错误:

Error:java.io.IOException: Duplicate zip entry 
[simple-xml-2.7.1.jar:org/simpleframework/xml/Attribute.class]

并且更详细(这里说: simple-xml-2.7.1.jar 但是我有像图像中那样的simple-xml-2.3.4.jar)

Error:java.lang.RuntimeException: java.io.IOException: Can't write [C:\Users\Alfonso\Documents\AndroidStudioProjectsNew\Business\VOIPMonitoring\app\build\intermediates\multi-dex\debug\componentClasses.jar] 
(Can't read [C:\Users\Alfonso\.gradle\caches\modules-2\files-2.1\org.simpleframework\simple-
xml\2.7.1\dd91fb744c2ff921407475cb29a1e3fee397d411\simple-xml-2.7.1.jar(;;;;;;**.class)] 
(Duplicate zip entry [simple-xml-2.7.1.jar:org/simpleframework/xml/Attribute.class]))


Caused by: java.io.IOException: Duplicate zip entry [simple-xml-2.7.1.jar:org/simpleframework/xml/Attribute.class]
at proguard.io.JarWriter.getOutputStream(JarWriter.java:138)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:92)
at proguard.io.ClassRewriter.read(ClassRewriter.java:68)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.JarReader.read(JarReader.java:65)
at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65)
at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53)
at proguard.InputReader.readInput(InputReader.java:184)

Associated Proguard文件为空。

在命令之后:gradlew clean我得到: enter image description here

这里的库(我正在使用外部库)

enter image description here

我的Progect build.gradle:

buildscript {
    repositories {
    jcenter()
    google()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.1.0'
    }
 }

 allprojects {
    repositories {
    jcenter()
        maven {
                url 'https://maven.google.com/'
                name 'Google'
        }
        maven { url  "https://dl.bintray.com/httprequester/maven" }
        maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/'}
    }
  }

  task clean(type: Delete) {
        delete rootProject.buildDir
    }

我的模块:android-ngn-stack build.gradle

 buildscript {
    repositories {
    jcenter()
    google()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    classpath 'com.google.gms:google-services:3.1.0'
}


allprojects {
 repositories {
     jcenter()
     maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven { url  "https://dl.bintray.com/httprequester/maven" }
        maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/'}
        }
}

task clean(type: Delete) {
        delete rootProject.buildDir
}

我的模块:app build.gradle我觉得有问题

    apply plugin: 'com.android.application'

    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven {
        url 'https://maven.google.com/'
        name 'Google'
        }
    }

    android {
        compileSdkVersion 25
        buildToolsVersion "26.0.2"
        defaultConfig {
            applicationId "monitoring.voip.business.tim.voipmonitoring"
            minSdkVersion 19
            targetSdkVersion 24
            multiDexEnabled true
            versionCode 3
            versionName "1.3"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
 }

dependencies {
        compile project(':android-ngn-stack')
        implementation 'com.android.support:support-v4:25.4.0'
        implementation 'com.google.firebase:firebase-config:11.0.4'
        compile fileTree(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
             exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile project(path: ':librarynetwork')
        compile 'com.android.support:appcompat-v7:25.4.0'
        compile 'com.android.support:animated-vector-drawable:25.4.0'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        compile 'com.android.support:design:25.4.0'
        compile 'com.android.support:recyclerview-v7:25.4.0'
        compile 'com.android.support:mediarouter-v7:25.4.0'
        testCompile 'junit:junit:4.12'
        compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
            transitive = true;
        }
        compile 'com.getkeepsafe.taptargetview:taptargetview:1.10.0'
        compile 'com.pnikosis:materialish-progress:1.7'
        compile 'com.loopeer.library:cardstack:1.0.2'
        compile 'com.github.aakira:expandable-layout:1.4.2@aar'
        // Room
        implementation "android.arch.persistence.room:runtime:1.0.0"
        annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
        compile 'ir.bpadashi.requester:requester:1.1.6'
        compile 'com.google.code.gson:gson:2.8.2'


}

configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
            if (requested.group == 'com.android.support') {
                    if (!requested.name.startsWith("multidex")) {
                        details.useVersion '25.0.0'
                    }
            }
        }
}

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

3 个答案:

答案 0 :(得分:1)

这可能是你的问题。您将simple-xml-2.3.4.jar放在依赖项中,而其他一些依赖项依赖于simple-xml-2.7.1.jar

使用./gradlew <module-name>:dependencies | grep simple-xml查明是否是这种情况并搜索使用它的依赖项。

最好不要使用simple-xml-2.3.4.jar进行编译,看看代码是否与simple-xml-2.7.1.jar一起运行。

答案 1 :(得分:0)

  

simple-xml-2.7.1.jar但我不会用它..

可能没有,但其中一个其他库

Simple XML JAR不是JNI库,所以我不知道你为什么要把它放在jniLibs中,但是......

删除您的JAR,改为使用此依赖

 compile 'org.simpleframework:simple-xml:2.7.1'

答案 2 :(得分:0)

几天后,我解决了我的问题,从一个新项目开始,并逐步添加依赖项

问题是由于我的gradle文件中的依赖项与我的外部库冲突造成的。

我发现这是感谢命令

    ./gradlew app:dependencies > dependencies.txt 

其中app是您的项目模块。

当您看到箭头( - &gt;)时,冲突问题已本地化。

您可以使用“排除模块”排除该依赖项,如下所示 (但我更喜欢从新的空项目开始,我将在之后排除依赖性问题)

举个例子,假设com.android.support:support-v4是带有导致这些错误的重复类的模块。以下是如何从依赖项中排除该重复模块:

//Your dependency that includes the module with the duplicates.
 compile('com.my.project:my-module:0.1') {
    //exclude the offending module so there won’t be duplicates.
    exclude module: 'support-v4'
    //maybe you need to exclude a group also?...
    exclude group: 'com.google.android.gms'
}

引用相同的解决方案

Prograurd Duplicate zip entry

Prograurd Duplicate zip entry