3

I have module gradle dependencies like this

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:+'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.firebase:firebase-core:11.6.2'
    implementation 'com.google.firebase:firebase-messaging:11.6.2'
    implementation 'com.google.android.gms:play-services-gcm:11.6.2'
    implementation 'com.google.android.gms:play-services-ads:11.6.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

and project gradle like this

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    classpath 'com.google.gms:google-services:3.1.2'
}

when i am syncing my project with gradle i am getting execution failed error

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 11.4.2.

But why? I have target SDK of 27, i am everywhere where i can already set to use latest packages, why studio asks me to downgrade com.google.android.gms to 11.4.2 ?

SDK Tools are enter image description here

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Itsmeromka
  • 3,621
  • 9
  • 46
  • 79
  • 1
    Maybe this will help: [Google Play Services GCM 9.2.0 asks to “update” back to 9.0.0](https://stackoverflow.com/questions/38127053/google-play-services-gcm-9-2-0-asks-to-update-back-to-9-0-0) – Septian Triadi Nov 29 '17 at 09:30
  • 1
    apply plugin: 'com.google.gms.google-services' must be on bottom, not top like i did. Not bad. Thank you :) – Itsmeromka Nov 29 '17 at 09:44

2 Answers2

3

As mentioned by the OP, the line

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

must be moved to the bottom of the app module build gradle file. This line should come after all google gms dependencies.

Shahzore
  • 73
  • 1
  • 7
0

Instead of

implementation 'com.android.support:appcompat-v7:+'
...
implementation 'com.google.firebase:firebase-core:11.6.2'
implementation 'com.google.firebase:firebase-messaging:11.6.2'
implementation 'com.google.android.gms:play-services-gcm:11.6.2'
implementation 'com.google.android.gms:play-services-ads:11.6.2'

use

implementation 'com.android.support:appcompat-v7:27.0.2'
...
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.android.gms:play-services-gcm:11.8.0'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
Sneh Pandya
  • 8,197
  • 7
  • 35
  • 50