user1938007
user1938007

Reputation: 459

runTransaction (com.firebase.client.Transaction.Handler) in Firebase cannot be applied to (anonymous com.google.firebase.database.Transaction.Handler)

I'm trying to get myself familiar with the basics of Firebase reading and writing using their docs. Anyways, they've got this tutorial on incrementing numeric values and I've tied it to a button to do this:

public void onClick(View view) {

                Firebase upvotesRef = ref.child("https://docs-examples.firebaseio.com/android/saving-data/fireblog/posts/-JRHTHaIs-jNPLXOQivY/upvotes");

                upvotesRef.runTransaction(new Transaction.Handler() {
                    @Override
                    public Transaction.Result doTransaction(MutableData currentData) {
                        if(currentData.getValue() == null) {
                            currentData.setValue(1);
                        } else {
                            currentData.setValue((Long) currentData.getValue() + 1);
                        }
                        return Transaction.success(currentData);
                    }

                    @Override
                    public void onComplete(DatabaseError databaseError, boolean b, DataSnapshot dataSnapshot) {

                    }
                });

            }

This is tied to a button in my layout and the code is exactly the same as the one in the tutorial, but this code gives me the following error before compiling:

runTransaction (com.firebase.client.Transaction.Handler) in Firebase cannot be applied to (anonymous com.google.firebase.database.Transaction.Handler)

Normally, I'd google the issue, but amazingly, no one seems to have had a similar problem, at least not that I could find, so I'm wondering if anyone here knows what the problem is?

Upvotes: 0

Views: 278

Answers (1)

user1938007
user1938007

Reputation: 459

In case anyone else ever finds themselves in a similar situation, the problem was that I was importing Transaction class from com.firebase.client instead of com.google.firebase.database

Upvotes: 1

Related Questions