I am getting below compilation error
Realm model classes must either extend RealmObject or implement RealmModel to be considered a valid model class
In this particular scenario
class Animals extends RealmObject {
}
class Dog extends Animals {
}
I am getting this error for the Dog class.
That error appears when I am indirectly extending RealmObject. i.e Dog is extending Animals (which in turns extends RealmObject), not RealmObject directly.
While the issue has not been closed yet, it is recommended to use composition instead of inheritance: F.ex. you could have
public interface Animalistic {
makeNoise();
}
which is then implemented by each animal.
Inheritance / Polymorphism is still an open issue in Realm, Check this link https://github.com/realm/realm-java/issues/761
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With