I am trying to add notification services to my app using FCM and tutorial given on https://www.simplifiedcoding.net/firebase-cloud-messaging-android/ Everything has done and
You must have all the google play service line in the same version:
compile 'com.google.android.gms:play-services:11.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.1'
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
Use something like this:
dependencies {
compile 'com.google.android.gms:play-services:11.0.1'
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
}
apply plugin: 'com.google.gms.google-services'
Make sure apply plugin comes below dependencies.
What finally saved me:
In android studio, switch to Project view instead of Android view. Delete .gradle folderm and also the gradle.properties file. Clean the project. Sync gradle again.
I have no clue why this worked. Deleting only the .gradle folder didn't do the job and the newly made gradle.properties is exactly the same as the old one! But my issue is fixed.
It's an Android Studio bug, it is NOT offering to automatically upgrade firebase libs like it does for play-services* libs.
autoupdate
compile 'com.google.android.gms:play-services-drive:10.0.1'
no autoupdate (need to manually up the version to same as play-services*)
compile 'com.google.firebase:firebase-messaging:10.0.1'
In your Gradle file all the versions of google-play-service and firebase should use the same version.
As you are using :
compile 'com.google.android.gms:play-services-drive:10.0.1'
You should use :
compile 'com.google.firebase:firebase-messaging:10.0.1'
// and not 9.2.1
Make sure your google service version matches your firebase version. currently compile 'com.google.android.gms:play-services-drive:10.0.1' does not match compile 'com.google.firebase:firebase-messaging:9.2.1' What you have to do is to change 'com.google.firebase:firebase-messaging:9.2.1' to 'com.google.firebase:firebase-messaging:10.0.1' so that the versions matches.