Google Play服务GCM 9.2.0要求"更新"回9.0.0

her*_*ell 178 android google-cloud-messaging google-play-services

所以今天早上我开始更新到我的项目库的最新版本.

我正在尝试将GCM更新到最新版本9.2.0,但是我收到此错误:

错误:任务':app:processDebugGoogleServices'的执行失败.请通过更新google-services插件的版本来修复版本冲突(有关最新版本的信息,访问https://bintray.com/android/android-tools/com.google.gms.google-services/)或将com.google.android.gms的版本更新为9.0.0.

这就是我的代码:

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.2'
    classpath 'com.google.gms:google-services:3.0.0'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
Run Code Online (Sandbox Code Playgroud)

然后:

dependencies {
    ...

    compile "com.google.android.gms:play-services-gcm:9.2.0"

    ...
}
Run Code Online (Sandbox Code Playgroud)

任何人有同样的问题/修复同样的问题?

谢谢.

编辑

显然你必须在app/build.gradle文件的底部应用你的GSM插件.否则,版本9.2.0将导致项目冲突.

作为参考,这就是我的app/build.gradle文件现在的样子:

apply plugin: "com.android.application"
apply plugin: "com.neenbedankt.android-apt"

android {
    ...
}

dependencies {
    ...

    // Google Cloud Messaging
    compile "com.google.android.gms:play-services-gcm:9.2.0"

    ...
}

apply plugin: "com.google.gms.google-services"
Run Code Online (Sandbox Code Playgroud)

Gus*_*ema 507

你有线吗?

apply plugin: 'com.google.gms.google-services' 
Run Code Online (Sandbox Code Playgroud)

应用程序build.gradle文件底部的行?

当它在顶部时我看到了一些错误,正如它在这里写的那样,它应该在底部.

  • 这不是真的,gms插件应位于文件的底部,您可以在gms的文档中看到:https://developers.google.com/android/guides/google-services-plugin (11认同)
  • 我在文件的开头添加了这一行,但是在将它放在底部之后它才起作用. (9认同)
  • 在底部添加插件解决了版本冲突. (2认同)

Vik*_*kas 54

只需将此行放在app-module(不是项目根目录)gradle文件的底部即可.

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

然后重建您的项目.


Gus*_*cls 11

我有同样的问题,今天2016年 - 10月 - 06我用这个解决了:

我改变了以9开头的所有依赖项.?.?到9.6.1我用sdk版本24和目标版本17编译.

我的解决方案中还有另一个软件包,因为我使用了更多的东

使用下面的代码更改build.gradle(Module:app)之后执行以下操作:

  1. 将您的包NAME放在包含applicationId"com.YOUR_PACKAGE_HERE"字样的行中

  2. 同步项目(Ctrl + alt + v)和Build Again.

这是适用于我的文件buid.gradle(Module:app)的代码:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId "com.YOUR_PACKAGE_HERE"
        minSdkVersion 24
        targetSdkVersion 17
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

    compile 'com.google.firebase:firebase-core:9.6.1'
    compile 'com.google.firebase:firebase-database:9.6.1'

    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'

    compile 'com.google.firebase:firebase-crash:9.6.1'
    testCompile 'junit:junit:4.12'

    compile 'com.google.firebase:firebase-messaging:9.6.1'

    compile 'com.google.firebase:firebase-ads:9.6.1'


    compile 'com.google.firebase:firebase-auth:9.6.1'


    compile 'com.google.android.gms:play-services:9.6.1'

}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)


yan*_*eq6 6

以前的版本也是如此.新的版本com.google.android.gms库总是在插件之前发布,并且不可能使用新版本,因为它与旧插件不兼容.我不知道现在是否需要插件(google docs很糟糕).我记得不是的时候.唯一的方法是等待新的插件版本,或者你可以尝试删除插件依赖项,但正如我所说,我不确定gcm是否可以在没有它的情况下工作.我所知道的9.2.0版本的主要功能是新的Awareness API https://inthecheesefactory.com/blog/google-awareness-api-in-action/en,如果你不需要它,你可以使用9.0. 0版本没有任何问题.


Rah*_*gal 5

Gustavomcls将com.google.*版本更改为相同版本的解决方案对我有用.

我在buid.gradle中将两个依赖项更改为9.2.1(模块:app)

compile 'com.google.firebase:firebase-ads:9.2.1'
compile 'com.google.android.gms:play-services:9.2.1'
Run Code Online (Sandbox Code Playgroud)