Gradle依赖项排除

时间:2017-04-13 02:05:01

标签: android firebase gradle build.gradle firebase-analytics

出于某种原因,我使用java 1.7来编译我的项目,但是在编译项目时我遇到了重复的输入错误。下面是我的依赖树,显示了重复。

+--- com.google.firebase:firebase-analytics:10.2.0
|    +--- com.google.firebase:firebase-common:10.2.0
|    |    +--- com.google.android.gms:play-services-basement:10.2.0
|    |    |    \--- com.android.support:support-v4:24.0.0
|    |    |         \--- com.android.support:support-annotations:24.0.0
|    |    \--- com.google.android.gms:play-services-tasks:10.2.0
|    |         \--- com.google.android.gms:play-services-basement:10.2.0 (x)
|    +--- com.google.firebase:firebase-analytics-impl:10.2.0
|    |    +--- com.google.android.gms:play-services-basement:10.2.0 (x)
|    |    +--- com.google.firebase:firebase-iid:10.2.0
|    |    |    +--- com.google.android.gms:play-services-basement:10.2.0 (x)
|    |    |    \--- com.google.firebase:firebase-common:10.2.0 (x)
|    |    +--- com.google.firebase:firebase-common:10.2.0 (x)
|    |    \--- com.google.android.gms:play-services-tasks:10.2.0 (x)
|    \--- com.google.android.gms:play-services-basement:10.2.0 (x)

我在编译firebase-analytics lib时尝试添加exclude,但看起来只会排除第一层,而不是全部。有人可以帮忙吗?

compile ('com.google.firebase:firebase-analytics:10.2.0'){
exclude group: 'com.google.android.gms', module: 'play-services-basement:10.2.0'
}

依赖块:

dependencies {
    compile project(":core")
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.code.gson:gson:2.7'
    compile ('com.google.firebase:firebase-core:10.2.0'){
        exclude group: 'com.google.android.gms', module: 'play-services-basement'
    }
    compile fileTree(dir: "${rootProject.projectDir}/android-libs", include: ['*.jar'])
    compile "org.slf4j:slf4j-android:1.7.10"
}

1 个答案:

答案 0 :(得分:3)

您可以尝试按如下方式使用配置范围的排除:

configurations.all {
    exclude group: 'com.google.android.gms', module: 'play-services-basement'
}

或者只是从编译配置中排除它:

configurations {
    compile.exclude group: 'com.google.android.gms', module: 'play-services-basement'
}