0

I am integrating Firebase messaging for a version. It is:

'com.google.firebase:firebase-messaging:15.0.2'

My classpath is:

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

I had faced the following error:

Failed to resolve: firebase-messaging Open File

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Bala
  • 41
  • 1
  • 8

3 Answers3

10

Change this:

classpath 'com.google.gms:google-services:3.2.0'
implementation 'com.google.firebase:firebase-messaging:15.0.2'

into this:

classpath 'com.google.gms:google-services:4.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'

Explanation:

Here in this case using firebase-messaging:15.0.2 with google-services:4.0.1 would work, since the most important thing was updating google-services above 3.2.0, and that's because google-services:3.3.0 is needed to be able to use the firebase library from version 15.0 and above. You can check this blog post. that explains the changes in versioning of firebase libraries.

But it is still better to update the google-services plugin to prevent any other errors with other dependencies.

Note:

The versions less than 15.0.0 are in google maven repository, so you can use them in gradle. But, you cannot mix version 15.0.0 with a version less than 15.0.0 and use google play services 4.0.1, as said in my answer here. That's why it is better to update firebase libraries to the latest versions.

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
  • Just curious, would it have also worked just updating to `classpath 'com.google.gms:google-services:4.0.1'` There should be a 15.0.2 version of firebase-messaging, as per maven.google.com – zfromg Jun 21 '18 at 13:44
  • 1
    yes I think `15.0.2` would work with `4.0.1`, but the most important thing was updating google-services above `3.2.0`, since `google-services 3.3.0` is needed to be able to use the firebase library from version 15.0 and above. But anyway when I answered this I used the latest version of both `google-services` and firebase libraries to prevent any other issues if he is using other firebase libraries. @ZhiQiao – Peter Haddad Jun 21 '18 at 13:50
  • Also the maven.google.com just lists all the libraries inside the google() repo, there is also version 9.0 for some firebase libraries like `firebase-auth`, but it wont work if you use it with `google-services:4.0.1` (don't use it anyway since it is very old). @ZhiQiao – Peter Haddad Jun 21 '18 at 13:51
  • Cool. Thanks for following up. Glad this worked out. Just a minor caveat that since this was an update across major version (i.e. 15.0.2 => 17.0.0) it could potentially introduce API-breaking changes. – zfromg Jun 21 '18 at 14:41
  • 1
    @ZhiQiao yes just to add The versions less than `15.0.0` are in google maven repo, so he can use them. But, he cannot mix version 15.0.0 with a version less than 15.0.0 and use google play services 4.0.1 (as said in this answer: https://stackoverflow.com/questions/50732704/cannot-access-zzbfm-class-file-zzbfm-not-found-firebase-android/50732851#50732851). That is why it is better just to update the firebase libraries to the latest version after they release them. Also yes ofcourse he needs to check the release notes after he updates. – Peter Haddad Jun 21 '18 at 15:52
1

According to the Guy4444 1 on the post 2 I have changed

implementation 'com.google.firebase:firebase-messaging:17.0.0:15.0.0'

to

implementation 'com.google.firebase:firebase-messaging:17.0.0'

and it solved the problem!

Seymur Mammadli
  • 1,724
  • 15
  • 13
0

I got it resolved by changing

this

implementation 'com.google.firebase:firebase-messaging:17.0.0:15.0.0'

to this

 implementation 'com.google.firebase:firebase-messaging:17.0.0'
Haris
  • 13,645
  • 12
  • 90
  • 121