dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile('com.google.android.gms:play-services-gcm:8.4.0') {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.google.android.gms'
}
compile ('com.google.android.gms:play-services-base:8.4.0') {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.google.android.gms'
}
compile('com.android.support:appcompat-v7:23.2.0') {
exclude module: 'animated-vector-drawable'
}
compile 'com.jakewharton:butterknife:7.0.1'
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile 'com.google.code.gson:gson:2.5'
compile('com.koushikdutta.ion:ion:2.+') {
exclude module: 'gson'
}
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1@aar'
compile 'com.github.androidprogresslayout:library:2.0.2@aar'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5@aar'
}
但每次我收到此错误时:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException:
duplicate entry: android/support/v4/widget/SimpleCursorAdapter$CursorToStringConverter.class
这是 gradlew -q dependency App:dependencies --configurationcompile
结果:
从底部可以看到,我没有添加 com.google.android.gms:play-services-measurement
lib,却无缘无故地显示?
找到解决方案
我在删除依赖项时检查了 gradle 的控制台,我看到了;
Dexing \app\build\intermediates\exploded-aar\com.github.JakeWharton\ViewPagerIndicator\2.4.1\jars\libs\android-support-v4.jar took 1499
这将最旧的 support-v4 库添加为 jar。我已从 build.gradle 中删除了 ViewPagerIndicator 依赖项并手动添加它的类。
现在最奇怪的问题已经解决了。
最佳答案
您要添加两倍的支持库 v4。
发生这种情况是因为您正在使用
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1@aar'
您将从 jitpack 获取此库。
This library 将支持库添加为 jar,而不是作为 gradle 依赖项。
这意味着pom文件没有依赖关系,你不能用gradle排除jar文件,因为jar在aar文件内部(没有pom,gradle怎么知道这些文件应该被排除?) .
您可以检查 jitpack 存储库中的文件:
关于java - 梯度错误:Execution failed for task ':app:transformClassesWithJarMergingForDebug' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35667336/