错误“请通过更新google-services的版本来解决版本冲突”

时间:2018-07-10 16:56:08

标签: android firebase google-play-services

(由Google翻译人员翻译)我搜索了Internet,到处都是人们只要更改build.gradle中的版本。请帮帮我。 我已经准备好更新gms插件,但是我该怎么做?

  

请通过更新以下版本来解决版本冲突:   google-services插件(有关最新版本的信息是   可在   https://bintray.com/android/android-tools/com.google.gms.google-services/)   或将com.google.android.gms的版本更新为16.0.1。

我的项目gradle:

buildscript {

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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

我的模块gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'Google Inc.:Google APIs:14'
    defaultConfig {
        applicationId "com.xxx.xxxxxxxx"
        minSdkVersion 14
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    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.2'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.google.firebase:firebase-core:11.8.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.android.gms:play-services-gcm:15.0.1'
}

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

4 个答案:

答案 0 :(得分:4)

更改此:

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

对此:

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

避免混合版本错误。

也将firebase-core依赖项更新为此:

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

https://firebase.google.com/support/release-notes/android

答案 1 :(得分:3)

您可以从此更新Google库的版本 https://developers.google.com/android/guides/setup

答案 2 :(得分:1)

我在使用 ionic Cordova 时遇到了同样的问题,并通过在平台/android/project.properties 中更改 GMS 版本来修复它

 "cordova-plugin-google-analytics": {
      "GMS_VERSION": "VERSION_NUMBER_MENTIONED_IN_THE_BUILD_ERROR"

在平台/android/android.json

cordova.system.library.6=com.google.android.gms:play-services-analytics: VERSION_NUMBER_MENTIONED_IN_THE_BUILD_ERROR

答案 3 :(得分:0)

使用如下

dependencies {
    ...
    implementation 'com.google.firebase:firebase-core:15.0.0'
    ...
}