Android Question Firebase Realtimedatabase

Alan dos Santos

Member
Licensed User
Longtime User
I'm following this tutorial here, but I have a little difficulty.

Whenever I click the button to send the message it returns me that error.

java.lang.ClassCastException: de.donmanfred.QueryWrapper cannot be cast to de.donmanfred.DatabaseReferenceWrapper


Sorry my google translate s2

B4X:
Sub btn_sendMessage_Click

    messageref.Initialize("messages", roomref.Child(childOftheOnlyRoom & "/messages") ,"message")
  
    Dim messagesitems As Map = CreateMap("senderId": auth.CurrentUser.Uid, "text": "Test Message 1")
  
   messageref.push.setValue(messagesitems,"rooms","messages")
  
End Sub
 

Alexander Stolte

Expert
Licensed User
Longtime User
try this, because since the last Update of the lib. the child does not work as before. For every new reference initialize without .child.

B4X:
messagesref.Initialize("room",realtime.getReference2("/rooms/roomid/messages"),"room")
 
Upvote 0

Alan dos Santos

Member
Licensed User
Longtime User
Its worked, now I will work on a way to display the messages, thank you very much for the patience man, I will wait for the update
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Please nmote that some of the methods does NOT retrurn a new reference but return a QUERY.
If you want to use the query as object then you need to use a Query type....

java.lang.ClassCastException: de.donmanfred.QueryWrapper cannot be cast to de.donmanfred.DatabaseReferenceWrapper

The result of the method you are using is a Query, not a DatabaseReference.
 
Upvote 0
Top