Android 生成apk时获取运行时错误

Android 生成apk时获取运行时错误,android,android-studio,gradle,android-gradle-plugin,build.gradle,Android,Android Studio,Gradle,Android Gradle Plugin,Build.gradle,当我试图用Android Studio 2.3生成apk时,我遇到了一个问题 我得到一个错误: 错误:任务“:app:transformClassesWithJarMergingForDebug”的执行失败。 com.android.build.api.transform.TransformException:java.util.zip.zipeException:重复条目:org/antlr/v4/runtime/antlErrorListener.class 我知道我的一些依赖项必须实现相同

当我试图用Android Studio 2.3生成apk时,我遇到了一个问题

我得到一个错误:

错误:任务“:app:transformClassesWithJarMergingForDebug”的执行失败。 com.android.build.api.transform.TransformException:java.util.zip.zipeException:重复条目:org/antlr/v4/runtime/antlErrorListener.class

我知道我的一些依赖项必须实现相同的方法,但我不知道是哪一种方法

这是我的依赖项

dependencies {
    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 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.graphql-java:graphql-java:2016-10-19T14-40-14'
    compile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services-appindexing:9.8.0'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'org.altbeacon:android-beacon-library:2.12.2'
    compile 'io.fotoapparat.fotoapparat:library:1.4.1'
    testCompile 'junit:junit:4.12'
}

谢谢

您可以通过以下方式排除依赖项中的antlr4:

compile('com.graphql-java:graphql-java:2016-10-19T14-40-14') {
   exclude module: 'antlr4'
}
您可以在此处找到相关问题:


在此处执行gradlew app:dependencies-configurationreleasecompileclasspath并发布输出。另外,请检查是否使用class App extends MultidexApplicationHi!的可能副本!谢谢您的回答,它起作用了,但我使用了配置{all*.exclude module:'antlr4'},因为其他依赖项也有antlr4,它起作用了!