Home > Software engineering >  Fixing the error code: "Can't convert object of type java.lang.String to type"
Fixing the error code: "Can't convert object of type java.lang.String to type"

Time:10-10

I'm creating my first Android app which is a forum app wherein users can post.

I read a lot of the same error, but I can't figure it out to solve my problem. I got the error once I call the method LoadPost(); which fetches the data from Direbase straight to my RecycleView.

enter image description here

See, IUSH...2Mon, count, and forumname are children that exist under the exact same (1st) node. So when reading the data from the database, the Firebase-UI library tries to map each child under the above reference into an object of type Post, which is actually not possible since the last two children are strings. To solve this, you have to move those two strings to a different location. As soon as inside that node will only exist Post objects, then the error will go away.

  • Related