是否可以覆盖库的依赖性

时间:2017-08-15 20:59:23

标签: android gradle android-gradle

我正在尝试使用某些库,但是我遇到了错误。

All com.google.android.gms libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 8.4.0, 10.2.1. Examples include com.google.android.gms:play-services:8.4.0 and com.google.android.gms:play-services-auth:10.2.1 less... (Ctrl+F1)

我认为这样的事情应该有效,但我仍然会得到同样的错误。

compile'com.example.x:library:2.0.0', {
    exclude group: 'com.android.support', module: 'support-compat'
}

是否可以让外部库使用我的应用程序的依赖关系,或者是否有解决方案呢?

谢谢。

2 个答案:

答案 0 :(得分:0)

运行Gradle依赖关系报告,以查看完整的依赖关系树。

执行命令

./gradlew -q dependencies <module-name>:dependencies --configuration compile

示例:

./gradlew -q dependencies app:dependencies --configuration compile

答案 1 :(得分:0)

当您必须使用多个com.google.android.gms时,库应该是相同的版本号。

现在你可以使用

one is  : 8.4.0
another one is : 10.2.1

必须更改为

之类的相同版本
com.google.android.gms:play-services:8.4.0
com.google.android.gms:play-services-auth:8.4.0 

com.google.android.gms:play-services:10.2.1
com.google.android.gms:play-services-auth:10.2.1

注意: 一旦你必须在com.google.android.gms:play-services中使用,那么就不需要使用特定的api(com.google.android.gms:play-services-auth)。 因为com.google.android.gms:play-services包含所有依赖项

希望这会对你有帮助......

相关问题