java.util.zip.ZipException:重复条目

java.util.zip.ZipException: duplicate entry

我一整天都在 Android Studio 中与这个错误作斗争。项目是从 eclipse 解决方案导入的。我一直在尝试实施为类似帖子列出的所有修复程序,但没有任何效果。我是 Android 初学者。

我很乐意提供任何进一步的信息。

错误:任务“:app:packageAllDebugClassesForMultiDex”执行失败。

java.util.zip.ZipException: duplicate entry: com/google/zxing/BarcodeFormat.class

请帮忙!!我应该尝试在 Eclipse 中将其设置为 运行 吗?

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.2'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.appname.android"
        minSdkVersion 8
        targetSdkVersion 18
        multiDexEnabled true
    }

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

dependencies {
    compile 'com.android.support:support-v4:22.1.1'
    compile files('libs/ksoap2-android-assembly-3.1.0-jar-with-dependencies.jar')
    provided files('libs/zxing-core.jar')
}

确保您拥有来自 SDK 管理器的最新构建工具和 SDK。我已将那些 jars 转换为 Gradle 依赖项。

build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' } // <-- added for ksoap
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.3' // <-- updated
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' } // <-- added for ksoap
    }
}

app/build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1" // <-- updated

    defaultConfig {
        applicationId "com.appname.android"
        minSdkVersion 8
        targetSdkVersion 22  // <-- updated
        // multiDexEnabled true  // <-- you do not need this
    }

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

dependencies {
    compile 'com.android.support:support-v4:22.1.1'
    compile 'com.google.code.ksoap2-android:ksoap2-android:3.4.0'
    // compile files('libs/ksoap2-android-assembly-3.1.0-jar-with-dependencies.jar') // <-- avoid using jars
    compile 'com.google.zxing:core:3.2.0'
    // provided files('libs/zxing-core.jar') // <-- avoid using jars
}

java.util.zip.ZipException:重复条目

我也面临同样的问题issue.But我已经解决了

这个问题主要发生在我们将项目从一个系统移到另一个系统时。所以一个系统gradle版本和SDK工具版本与其他系统不同

请检查您的工程是从其他系统导入的还是从网上下载的

1.gradle 您的系统版本和下载的应用程序是否匹配?

  1. 和SDK工具配套不?

如果项目在同一个系统中,但是你得到了相同的异常,那么上面的解决方案可能会有所帮助。

我的问题是应用程序 "dependencies" 的版本低于系统 sdk 工具版本。

我们应该根据您的系统 SDK 工具版本为您的应用程序的每个依赖项提供正确的版本。

我认为 Android 工作室可能让我们感到困惑。该异常应该是系统 SDK 工具版本与应用程序依赖项版本不匹配。

在我的应用程序中,依赖项之一是 "support-v7" 版本是 24.1.1,但我的系统具有 "support-v7:24.2.0"。所以我被更改为最新版本。然后我的问题就解决了。