Trying to use firebase: "can not resolve FirebaseMessagingService"

3

I'm trying to use firebase for background notifications.

but it does not detect FirebaseMessagingService attempt extends of this and it tells me:

  

can not resolve

in the gradle I have

dependencies {
        classpath 'com.google.gms:google-services:4.1.0'
}

compile 'com.google.firebase:firebase-core:16.0.4'
compile 'com.google.firebase:firebase-messaging:9.8.0'

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

but if I do an import I get com.google.firebase.messaging. and after this R o *, I do not get the other options for example FirebaseMessagingService or FirebaseInstanceIdService within (iid) although I've already seen that in the documentation that can not be used.

I want to obtain and update the token.

    
asked by mabts 12.12.2018 в 17:36
source

2 answers

4

Ensure that the dependencies are within the dependencies block and that apply plugin: 'com.google.gms.google-services' is defined in the root of your build.gradle file:

dependencies {
    ...
    ...

    compile 'com.google.firebase:firebase-core:xx.x.x'
    compile 'com.google.firebase:firebase-messaging:xx.x.x'
    ...
    ...
}

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

I think your project is not updated, if you update it and use a gradle version 3.0 or higher you would have to change compile by implementation :

implementation 'com.google.firebase:firebase-core:xx.x.x'
implementation 'com.google.firebase:firebase-messaging:xx.x.x'

Since the use compile is obsolete, I suggest you use at least the version

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

Review the documentation:

Set up a Firebase Cloud Messaging client app on Android

    
answered by 12.12.2018 в 21:08
0

I have updated the gradle version, as you indicated in your answer. using now implementation. But this was not the solution. The problem was the version of the library that I was compiling.

I've updated to implementation 'com.google.firebase:firebase-messaging:17.3.4' and I can already do extends FirebaseMessagingService

Thank you for your answer Jorgesys

Greetings.

    
answered by 13.12.2018 в 11:44