错误的解决方案:执行失败的任务':app:transformClassesWithJarMergingForDebug'

时间:2018-01-10 20:45:34

标签: android android-studio compiler-errors duplicates

我尝试编译并且没有错误,但是当我想运行应用程序时,我收到此错误:

Error:Execution failed for task 
':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: 
java.util.zip.ZipException: duplicate entry: 
com/google/gson/annotations/Expose.class

我的依赖关系是:

    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 files('src/include/gson-2.8.2-SNAPSHOT.jar')
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:23.2.0'
    compile 'io.searchbox:jest-droid:2.0.1'
    testCompile 'junit:junit:4.12'

1 个答案:

答案 0 :(得分:1)

我注意到您的问题与this

重复

正如该问题中接受的答案所述,您必须在此处多次编译GSON

  

编译文件(' src / include / gson-2.8.2-SNAPSHOT.jar')

在另一个图书馆......我会假设这个:

  

编译' io.searchbox:jest-droid:2.0.1'

所以我建议复制你所接受的项目答案,如下:

compile('io.searchbox:jest-droid:2.0.1') {
exclude module: 'gson'
}