我尝试编译,但没有错误,但是当我想运行应用程序时,出现以下错误:

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'

最佳答案

我注意到您的问题是this的副本

作为该问题的公认答案,您必须在这里多编译GSON



在另一个库中...我要假设它是这个库:



因此,我建议为您的项目复制可接受的答案,如下所示:

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

09-10 07:21
查看更多