其他分享
首页 > 其他分享> > android-Gradle依赖关系排除

android-Gradle依赖关系排除

作者:互联网

由于某种原因,我已经使用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库时添加排除,但是看起来只有第一层将被排除,而并非全部.有人可以帮忙吗?

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"
}

解决方法:

您可以尝试使用配置范围内的排除,如下所示:

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

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

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

标签:firebase-analytics,firebase,build-gradle,gradle,android
来源: https://codeday.me/bug/20191111/2020221.html