Android Firebase Unable To Instantiate Abstract Class When Call Getvalue() In Listener
I have a outfit class that has an abstract class as one of its attributes. When I listen for changes in the database I get this error java.lang.RuntimeException: java.lang.Instanti
Solution 1:
Your concrete Outfit
class has fields and properties that define Item
:
publicclassOutfitimplementsParcelable{
private List<Item> itemList = newArrayList<>();
...
public List<Item> getItemList()
This means that the Firebase SDK will try to instantiate an Item
, which isn't possible due to it being abstract. Most likely you want Firebase to instantiate the right (concrete) subtype of Item
when it's reading the data, but it has no way to know what subtype that is.
You will either have to mark Item
as non-abstract, or you will have to mark the itemList
as having a specific concrete subtype of Item
.
Post a Comment for "Android Firebase Unable To Instantiate Abstract Class When Call Getvalue() In Listener"