Skip to content Skip to sidebar Skip to footer

Cannot Resolve Method Addoncompletelistener

Part of my program is given below. I try works with firebase. bit I have a lot of problems with this method. subscribeButton.setOnClickListener(new View.OnClickListener() {

Solution 1:

You are getting that error because you are missing some dependencies.

FirebaseMessaging.getInstance().subscribeToTopic("news")

Returns a Task<Void> object. In order to attach a listener on this object, you need to add the following dependencies to build.gradle file:

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

According to your build.gradle file, you also should change this line of code:

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

to

implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.1'

And also don't forget to add:

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

In the other build.gradle file.

Post a Comment for "Cannot Resolve Method Addoncompletelistener"