gradle 同步失败并出现 1 条警告请通过将 google-services 插件的版本更新到 16.0.4 来修复版本冲突

gradle sync failed with 1 warning Please fix the version conflict either by updating the version of the google-services plugin to 16.0.4

我尝试了所有可能的方法,但仍然无法同步,请帮忙。下面是我的整个 gradle 文件,我试图合并 firebase 核心和消息传递,但它仍然显示错误

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })


    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    implementation 'com.google.firebase:firebase-database:16.0.4'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
    implementation 'com.google.firebase:firebase-storage:16.0.4'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.firebaseui:firebase-ui-database:1.1.1'
    implementation 'id.zelory:compressor:2.1.0'
    implementation 'com.squareup.okhttp:okhttp:2.5.0'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.github.arturogutierrez:badges:1.0.5@aar'
    implementation 'com.github.broakenmedia:CharCountTextView:v1.0'
    implementation 'com.github.broakenmedia:MultiContactPicker:1.8.3'
    implementation 'com.github.lguipeng:BubbleView:1.0.1'
    implementation 'com.rockerhieu.emojicon:library:1.3.3'
    implementation 'com.android.support:cardview-v7:27.1.1'

}


apply plugin: 'com.google.gms.google-services'

下面是错误信息

请通过更新 google-services 插件的版本(有关最新版本的信息可在 https://bintray.com/android/android-tools/com.google.gms.google-services/ 获得)或更新 com.google.android.gms 的版本来修复版本冲突到 16.0.4.

在您的 project build.gradle 文件中,替换为以下行:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        compile 'com.google.gms:google-services:4.2.0'//the latest version is 4.2.0

    }
}

您正在使用不同版本的 firebase 依赖项。这可能是失败的原因。将 google-services 更新到最新版本并对 firebase 依赖项使用相同版本..

// as you can see different versions for firebase dependecies
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-database:16.0.4'

使用 16.0.4 或最新版本的 firebase 依赖项。