我不确定这个错误意味着什么。
Execution failed for task ':excelSior:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/util/TimeUtils.class
我目前正在使用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'
}
在gradle sync期间不会显示错误。就在我尝试运行应用程序时
可能是什么问题?
答案 0 :(得分:82)
你现在可能已经解决了这个问题,但这样做并没有得到解决,
尝试将其添加到build.gradle
:
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
答案 1 :(得分: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'
}
}
它对我有用!你可以尝试一下!
答案 2 :(得分:25)
重新导入旧的Eclipse项目时,我也遇到过这种问题。它在项目中发生了一些旧的依赖项作为jar文件。
删除
编译fileTree(dir:' libs',包括:' * .jar')
在gradle文件中
并在gradle文件中添加依赖项。
对我有用..
答案 3 :(得分:13)
在我的案例中提到的"重复条目"在build.gradle中设置multiDexEnable=true
后出现错误。
为了完全解决错误,请首先查看Configure Apps with Over 64K Methods(特别是"使用Gradle配置应用程序的Multidex")。
此外,搜索导致"重复输入的类的出现"在Android Studio中使用ctrl + n时出错。确定包含副本的模块和依赖项,并将其从构建中排除,例如:
compile ('org.roboguice:roboguice:2.0') {
exclude module: 'support-v4'
}
我必须尝试多个模块标签才能工作。排除" support-v4"解决与" java.util.zip.ZipException相关的问题:重复条目:android / support / v4 / *"
答案 4 :(得分: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'
在上面的例子中,我包含在我的libs目录(theOffendingAAR)中的aar文件包含了Google Play Services jar(是的,我知道。),而我的BaseApp构建文件使用了位置服务:
compile 'com.google.android.gms:play-services-location:6.5.87'
您可以安全地从构建文件中删除违规项目,清理并重建(如有必要,请重复)。
答案 5 :(得分:8)
检查您的依赖项版本,您必须具有兼容的版本,特别注意com.google包,必须具有相同的版本,如:
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'
两者都是8.3.0,如果你有另一个版本,编译将抛出该异常。
答案 6 :(得分:5)
简单从依赖项gradle.project中删除Jar文件为v7 并运行您的项目
答案 7 :(得分:5)
对于Expose.class错误,即
java.util.zip.ZipException:重复条目:com / google / gson / annotations / Expose.class
使用以下代码
configurations {
all*.exclude module: 'gson'
}
答案 8 :(得分:3)
找出lib取决于支持v4,并将其排除。
build.gradle
中的代码是这样的:
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
// http://stackoverflow.com/a/30931887/5210
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
在我的情况下,lib' espresso'有一个叫做support-v4的jar,在我的项目中有一个app'拥有相同的support-v4,在导入espresso时排除support-v4。
PS:似乎compile project
无法使用exclude
答案 9 :(得分:1)
这是因为您添加了一个库,并且多次依赖于模块。
就我而言,我已经添加了一个库作为模块和gradle依赖。
删除一个添加库的源(我删除了gradle依赖项)解决了我的问题。
答案 10 :(得分:0)
我尝试了上述所有解决方案,但对我不起作用。我尝试通过转到项目结构>应用程序更新库。它对我有用!希望这个答案对某人有用。
答案 11 :(得分:0)
对我来说,意外添加时发生了类似的情况
apply plugin: 'kotlin-android'
到我的android库模块。删除该行可解决此问题。
答案 12 :(得分:0)
只需擦除android / support / v4 / util / TimeUtils.class
答案 13 :(得分:0)
在我的情况下,确切错误低于
':机器人:transformClassesWithJarMergingForDebug'
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com / google / android / gms / internal / zzqx.class
我正在使用另一个版本的google apis,即在一个模块gradle文件中
if (!project.hasProperty('gms_library_version')) {
ext.gms_library_version = '8.6.0'
}
然而在其他模块版本11.6.0中如下
compile "com.google.android.gms:play-services-ads:11.6.0"
compile "com.google.android.gms:play-services-games:11.6.0"
compile "com.google.android.gms:play-services-auth:11.6.0"
然而,为了找到这个我在android studio中做了一个ctrl + n并输入了类名zzqx.class然后它显示了为这个类提取的2个jar文件,然后我明白了我正在使用版本8.6.0。在将8.6.0更改为11.6.0并重建项目时,问题已得到解决。
希望这会有所帮助。
答案 14 :(得分:0)
在我的情况下,在build.gradle中设置了multiDexEnable = true之后出现了提到的“重复条目”错误。
我得到的确切错误如下:
Error:Execution failed for task
':android:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
com/google/android/gms/internal/zzqx.class
首先,我在Android Studio中使用ctrl + n搜索导致“重复输入”错误的类并搜索com / google / android / gms / internal / zzqx.class,然后显示2个gms类条目一个版本8.4.0和一个版本11.6.0。
要修复它我同时使用11.6.0并且它是固定示例
早些时候
compile "com.google.android.gms:play-services-games:11.6.0"
compile "com.google.android.gms:play-services-auth:8.4.0"
compile "com.google.android.gms:play-services-ads:11.6.0"
在
compile "com.google.android.gms:play-services-games:11.6.0"
compile "com.google.android.gms:play-services-auth:11.6.0"
compile "com.google.android.gms:play-services-ads:11.6.0"
重建固定。
答案 15 :(得分:0)
我也有这个问题因为我编译'com.android.support:appcompat-v7:24.0.0-alpha1'但是我添加了recyclerview liberary compile'com.android.support:recyclerview-v7:24.0.2 '..i将版本改为与compat一样(24.0.2 intead of 24.0.0)。
我得到了答案。可能对某人有帮助。
答案 16 :(得分:0)
这个问题花了我一整天的时间。我最终将firebase-ui库版本从2.0.0降级到1.2.0并在Project level build.gradle文件中添加了以下代码:
allprojects {
repositories {
jcenter()
// Add the following code to your project level build.gradle
maven {
url 'https://maven.fabric.io/public'
}
}
}
答案 17 :(得分:0)
升级android SDK后我遇到了同样的问题。我能够在buildToolsVersion '23.0.1'
中运行该应用程序,当我更改为buildToolsVersion '24.0.3'
时出现了同样的错误
我通过使用compileSdkVersion 24
答案 18 :(得分:0)
我遇到过这个问题,因为我手动复制了libs中的jar,并提到了gradle文件中的依赖项。您还要检查项目结构,是否在libs或项目文件夹中的任何其他文件夹中复制相同的jar文件。
答案 19 :(得分:0)
错误:任务执行失败':app:transformClassesWithJarMergingForDebug'com.android.build.api.transform.TransformException java.util.zip.ZipException重复条目com / google / gson / annotations / Expose.class
这是我做的:
1)删除gson-2.5.jar文件。 2)配置{all * .exclude module:'gson-2.5'}
答案 20 :(得分:-1)
试试这个:
android {
configurations {
all*.exclude module: 'PhotoView' //去除重复依赖库
}
}