Search code examples
javaandroiddata-bindingrealmandroid-databinding

Trying to make an object that stores an ObservableArrayList extend RealmObject, but Android project does not compile


I have an object like so:

public class SubredditAddition extends RealmObject {

    @PrimaryKey
    private String mSubredditName;

    private ObservableArrayList<Keyword> mKeywords = new ObservableArrayList<>();
}

When I try to compile the program, I get the following error from Gradle:

Error:(13, 8) error: Field "mKeywords" of type "android.databinding.ObservableArrayList<Keyword>" is not supported.

Warning:Unclosed files for the types '[io.realm.SubredditAdditionRealmProxy]'; these types will not undergo annotation processing

Is there any way I can store an ObservableArrayList in realm?


Solution

  • Fixed it be creating an empty class like so:

    public class RealmObservableArrayList<T> extends ObservableArrayList implements RealmModel {
    
    }