java.util.zip.ZipException:packageAllDebugClassesForMultiDex期间的重复条目

bma*_*man 117 android android-support-library android-gradle-plugin android-multidex

我不确定这个错误意味着什么.

Execution failed for task ':excelSior:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/util/TimeUtils.class
Run Code Online (Sandbox Code Playgroud)

我目前正在使用android-support-v4.jar我的库

dependencies {
    compile project(':addThisSDK')
    compile project(':centeredContentButton')
    compile project(':googleplayservices_lib')
    compile files('libs/adxtag2.4.6.jar')
    compile files('libs/android-support-v4.jar')
    compile files('libs/aws-android-sdk-1.7.1.1-debug.jar')
    compile files('libs/commons-lang-2.6.jar')
    compile files('libs/crittercism_v4_4_0_sdkonly.jar')
    compile files('libs/dd-plist.jar')
    compile files('libs/FiksuAndroidSDK_4.1.1.jar')
    compile files('libs/iqengines-sdk-barcode.jar')
    compile files('libs/irEventTracker-1.2.jar')
    compile files('libs/jolt-core-0.0.7.jar')
    compile files('libs/json-utils-0.0.7.jar')
    compile files('libs/jsoup-1.7.2.jar')
    compile files('libs/kooaba-api-v4-java.jar')
    compile 'com.android.support:multidex:1.0.0'
}
Run Code Online (Sandbox Code Playgroud)

在gradle sync期间,错误不会显示.就在我尝试运行应用程序时

可能是什么问题呢?

zwe*_*bie 82

你可能现在已经解决了这个问题但是这样做并没有得到解决,请尝试将其添加到您的build.gradle:

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}
Run Code Online (Sandbox Code Playgroud)

  • 是否有任何正确的解决方案.我遇到同样的问题java.util.zip.ZipException:重复条目:com/google/gson/annotations/Expose.class (9认同)
  • 我添加了配置行,但仍然是"错误:任务执行失败":分析师:packageAllDebugClassesForMultiDex'.> java.util.zip.ZipException:重复条目:com/android/vending/billing/IInAppBillingService $ Stub $ Proxy.class`它显示. (4认同)
  • 我得到的消息无法解析符号'全部' (3认同)
  • 你是怎么解决这个问题的? (2认同)
  • 我收到消息`无法解决符号'排除'` (2认同)
  • 错误:(5,30)错误:包android.support.v4.app不存在添加答案后出现此错误 (2认同)

Gee*_*des 64

您需要检查是否已插入v4库并编译库?您不得在应用程序或依赖程序中重复库.

删除重复库,以便只剩下一个V4.

在你的app dir build.gradle文件中添加以下命令:

android{


    configurations {
        all*.exclude group: 'com.android.support', module: 'support-v4'
        all*.exclude group: 'com.android.support', module: 'support-annotations'
    }

}
Run Code Online (Sandbox Code Playgroud)

这个对我有用!你可以尝试一下!

  • 添加这些片段后,无法得到v4的支持,任何想法? (19认同)

Par*_*mal 25

在重新导入旧的Eclipse项目时,我也遇到过这种问题.它在项目中发生了一些旧的依赖项作为jar文件.

只是删除

编译fileTree(dir:'libs',包括:'*.jar')

在gradle文件中

并在gradle文件中添加依赖项.

这个对我有用 ..

  • 我为什么要相信一个名叫索伦的人呢? (17认同)

b00*_*n12 13

在我的情况下multiDexEnable=true,在build.gradle中设置后出现了提到的"重复条目"错误.

为了完全解决错误,首先要看看使用超过64K方法配置应用程序(特别是"使用Gradle为Multidex配置应用程序").

此外,在Android Studio中使用ctrl + n搜索导致"重复输入"错误的类的出现.确定包含副本的模块和依赖项,并将其从构建中排除,例如:

compile ('org.roboguice:roboguice:2.0') {
    exclude module: 'support-v4'
}
Run Code Online (Sandbox Code Playgroud)

我不得不尝试多个模块标签,直到它工作.排除"support-v4"解决了与"java.util.zip.ZipException:重复条目:android/support/v4/*"相关的问题


use*_*101 9

我的理解是有相同API的重复引用(可能不同的版本号).从命令行构建时,调试应该相当容易.

./gradlew yourBuildVariantName --debug从命令行尝试.

违规项目将是第一次失败.示例可能如下所示:

14:32:29.171 [INFO] [org.gradle.api.Task] INPUT: /Users/mydir/Documents/androidApp/BaseApp/build/intermediates/exploded-aar/theOffendingAAR/libs/google-play-services.jar

14:32:29.171 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':BaseApp:packageAllyourBuildVariantNameClassesForMultiDex'

14:32:29.172 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :BaseApp:packageAllyourBuildVariantNameClassesForMultiDex FAILED'
Run Code Online (Sandbox Code Playgroud)

在上面的例子中,我包含在我的libs目录(theOffendingAAR)中的aar文件包含了Google Play Services jar(是的,我知道.),而我的BaseApp构建文件使用了位置服务:

compile 'com.google.android.gms:play-services-location:6.5.87'
Run Code Online (Sandbox Code Playgroud)

您可以安全地从构建文件中删除有问题的项目,清理并重建(如有必要,请重复).


Nin*_*ing 8

检查您的依赖项版本,您必须具有兼容的版本,特别注意com.google包,必须具有相同的版本,如:

compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'
Run Code Online (Sandbox Code Playgroud)

两者都是8.3.0,如果你有另一个版本编译将抛出该异常.


小智 5

简单从依赖项gardle.project中删除您的Jar文件作为v7并运行您的项目


小智 5

对于Expose.class错误即

java.util.zip.ZipException:重复条目:com/google/gson/annotations/Expose.class

使用以下代码

configurations {
    all*.exclude  module: 'gson'
}
Run Code Online (Sandbox Code Playgroud)

  • OP对'gson`一无所知. (11认同)