我的 Android 项目的 app 模块的 build.gradle 中有以下代码
implementation('com.google.firebase:firebase-core:16.0.1', {
exclude group: 'com.android.support'
})
implementation('com.google.firebase:firebase-database:16.0.1', {
exclude group: 'com.android.support'
})
implementation('com.google.firebase:firebase-auth:16.0.1', {
exclude group: 'com.android.support'
})
implementation('com.google.firebase:firebase-crash:16.0.1', {
exclude group: 'com.android.support'
})
firebase 库都包含我正在使用的 android 支持库的冲突版本,因此我需要将其排除以防止生成警告
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 26.1.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:support-media-compat:26.1.0 less... (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).
有没有办法可以将这些实现语句组合在一起,所以我只需要编写一个排除语句?
编辑
我的具体解决方案基于 Cris 的回答
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.android.support') {
details.useVersion '27.1.1'
}
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-crash:16.0.1'
}