Digit
Digit

Reputation: 1939

extending abstract class in realm giving error

i have a class A

public  abstract class A extends RealmObject{

}

public class B extends A {

}

error: A RealmClass annotated object must be derived from RealmObject

Upvotes: 4

Views: 1823

Answers (3)

EpicPandaForce
EpicPandaForce

Reputation: 81539

Inheritance is not supported (answer based on v1.1.0), only interface implementation is.

Upvotes: 0

Niroj
Niroj

Reputation: 1114

To me I solved this issue by removing the dependency.

compile 'io.realm:realm-android:1.1.0'

and put the class path as:

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath "io.realm:realm-gradle-plugin:1.1.0"
}
}

and also put plugin as:

apply plugin: 'realm-android'

Further you can visit to Realm

Upvotes: -1

mguellsegarra
mguellsegarra

Reputation: 465

As far as I know, subclassing a subclass of RealmObject isn´t supported by Realm in Android for the moment, but there's already a feature in their roadmap in order to improve this point ( https://github.com/realm/realm-java/issues/761 ).

At least, you can always duplicate fields between model classes, to simulate subclassing (not very elegant though).

Upvotes: 5

Related Questions