Skip to content
Advertisement

Getting error : Could not deserialize object. Failed to convert a value of type java.lang.String to long

enter image description hereI have tried changing values many times. Now I have the same values in Firebas. It’s working if I give the values manually in code, but it’s not working while I try to get the info from Firestore. But still, I’m getting this error continuously:

JavaScript

That’s my Model’s code

JavaScript

}

My adapter code

JavaScript

}

Main Activity

JavaScript

}

I cannot find a solution for this. Please help me fix this. Thank you.

Advertisement

Answer

You are getting the following error:

java.lang.RuntimeException: Could not deserialize object. Failed to convert a value of type java.lang.String to long (found in field ‘matchNumber’)

Because your matchNumber field is defined in your class as a long, while in database holds a String value. To get rid of this Exception, please change the type of the field to be a Number and not a String, for example:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement