在gradle中使用相同版本的依存关系时出现错误

时间:2018-09-11 16:54:32

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

我对为什么此方法不起作用感到困惑,因为我以前的版本可以使用,但是它们是较低的版本:

implementation 'com.google.firebase:firebase-database:12.0.1'
implementation 'com.google.firebase:firebase-storage:12.0.1'
compile 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.google.firebase:firebase-auth:12.0.1'

但是,当我尝试升级到较新版本时,此图像中出现错误:

enter image description here

它说我正在混合版本,但是我没有,因为我把它们都放了。

All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 15.1.0, 15.0.2, 15.0.1, 15.0.0. Examples include `com.google.firebase:firebase-iid:15.1.0` and `com.google.android.gms:play-services-measurement-base:15.0.2`

2 个答案:

答案 0 :(得分:2)

从2018年5月开始:

  

Firebase Android SDK现在具有独立的版本号,可以进行更频繁,更灵活的更新。

根据this,请更改以下代码行:

implementation 'com.google.firebase:firebase-database:12.0.1'
implementation 'com.google.firebase:firebase-storage:12.0.1'
implementation 'com.google.firebase:firebase-auth:12.0.1'

implementation 'com.google.firebase:firebase-database:16.0.2'
implementation 'com.google.firebase:firebase-storage:16.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.3'

根据this,请更改以下代码行:

compile 'com.google.android.gms:play-services-auth:12.0.1'

implementation 'com.google.android.gms:play-services-auth:16.0.0'

根据this,请更改以下代码行:

implementation 'com.firebaseui:firebase-ui-auth:3.1.0'

implementation 'com.firebaseui:firebase-ui-auth:4.1.0'

还请添加以下依赖项,现在这是强制性的:

implementation 'com.google.firebase:firebase-core:16.0.3'

还请确保在顶级build.gradle文件中也使用Google Play服务的最新版本:

classpath 'com.google.gms:google-services:4.1.0'

答案 1 :(得分:1)

Project gradle中的更改依赖项

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:4.0.1'
}

和模块

implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-storage:16.0.2'
implementation 'com.firebaseui:firebase-ui-database:4.1.0'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.google.firebase:firebase-config:16.0.0'