Android工作室。重复条目:org/slf4j/helpers/BasicMarker.class

Android studio. Duplicate entry: org/slf4j/helpers/BasicMarker.class

在我将 Graphhoper 添加到我的项目中之后 - 我遇到了一个问题。我是 Android 的新人,请帮助我。 据我了解,我必须从编译代码中排除这个 class 吗?但是怎么办?谁能给我看看

错误:任务“:transformClassesWithJarMergingForRelease”执行失败。

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/slf4j/helpers/BasicMarker.class

这是我的 gradle 文件

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.journeyapps:zxing-android-embedded:3.0.1@aar'
    compile 'com.google.zxing:core:3.2.0'
    compile 'com.google.code.gson:gson:2.5'
    compile 'com.squareup.okhttp3:okhttp:3.3.1'
    compile 'com.github.MKergall:osmbonuspack:5.9'
    compile 'com.google.android.gms:play-services:10.0.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'net.lingala.zip4j:zip4j:1.3.2'

    compile('com.graphhopper:graphhopper:0.8-SNAPSHOT') {
        exclude group: 'com.google.protobuf', module: 'protobuf-java'
        exclude group: 'org.openstreetmap.osmosis', module: 'osmosis-osm-binary'
        exclude group: 'org.apache.xmlgraphics', module: 'xmlgraphics-commons'
    }
    compile 'org.mapsforge:mapsforge-core:0.6.1'
    compile 'org.mapsforge:mapsforge-map:0.6.1'
    compile 'org.mapsforge:mapsforge-map-android:0.6.1'
    compile 'org.mapsforge:mapsforge-map-reader:0.6.1'

    /*
            compile group: 'org.slf4j', name: 'slf4j-android', version: '1.7.12'
            compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.12'
        */
}

repositories {
    jcenter()
}

android {
    compileSdkVersion 23
    buildToolsVersion "22.0.1"
    defaultConfig {
        multiDexEnabled true
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
    productFlavors {
    }
    dexOptions {
    }
}

apply plugin: 'com.google.gms.google-services'

尝试使用以下依赖项,它对我有用,

compile 'org.slf4j:slf4j-android:1.7.21'

并确保只添加一次。

我找到了解决办法。问题出在这部分

compile fileTree(include: ['*.jar'], dir: 'libs')

有旧版本的库。谢谢大家的帮助