通过更新google-services的版本或更新com.google.android.gms的版本来修复版本冲突

时间:2017-08-16 23:00:04

标签: android firebase android-gradle google-play-services firebase-cloud-messaging

我只是尝试使用Firebase Cloud Messaging,但我收到了错误消息。这是我第一次这样做,所以我认为可能是某种位置服务的版本。我已经放了几个库,但我不确定是什么问题。 Firebase正在制造一些问题。

Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.2.6.

这是我的Gradle(应用)。

apply plugin: 'com.android.application'
android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.xxx.xxx.xxx"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
        }
    }
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}

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

    allprojects {
        repositories {
            // Add this line
            maven { url "https://jitpack.io" }
        }
    }
    compile('com.wdullaer:materialdatetimepicker:3.2.2') {
        exclude group: 'com.android.support'
    }
    compile 'com.google.firebase:firebase-core:10.2.6'
    compile 'com.github.Mariovc:ImagePicker:1.2.0'
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:26.+'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.google.android.gms:play-services-location:11.0.4'
    compile 'com.android.support:support-v4:26.0.0-alpha1'
    compile 'com.google.android.gms:play-services-maps:11.0.4'
    compile 'com.android.support:cardview-v7:26.0.+'
    compile 'com.android.support:recyclerview-v7:26.0.+'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

这是另一个Gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

请帮助我,我匆忙

3 个答案:

答案 0 :(得分:2)

您正在使用相同库的不同版本:

compile 'com.google.firebase:firebase-core:10.2.6'
compile 'com.google.android.gms:play-services-location:11.0.4'

您可以使用:

compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'

或者您可以切换到最新的稳定版本:

compile 'com.google.firebase:firebase-core:11.2.0'
compile 'com.google.android.gms:play-services-location:11.2.0'

此版本需要添加google maven repo。

    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }

有关google play services herefirebase here的发布的详细信息。

另外你应该使用稳定版:

compile 'com.android.support:support-v4:26.0.0'

答案 1 :(得分:0)

尝试将firebase版本更改为以下内容:

    compile 'com.google.android.gms:play-services:11.0.2'
    compile 'com.google.firebase:firebase-core:11.0.2'

并添加播放服务

答案 2 :(得分:0)

如果未将apply plugin: 'com.google.gms.google-services'添加到app/build.gradle的底部,也会发生此错误。我碰巧忽略了它并将其添加到apply plugin: 'com.android.application'下面。