Search code examples
javaandroidrealm

Cannot import realm classes in Android Studio


I'm using android studio 2.1.3, gradle version 2.1.3 , realm 2.2.1 and java 8

I can import classes like

io.realm.Realm;
io.realm.RealmQuery;
io.realm.RealmResults;

and project compiles successfully

but I cannot import classes like

io.realm.SyncCredentials;
io.realm.ObjectServerError;
io.realm.SyncUser;

basically object server related classes. for some reason studio cannot find those classes. I've included correct code in both the build.gradle files.

any suggestions ?


Solution

  • In order to enable sync classes, you need to enable sync in the Realm plugin.

    Enabling Realm Mobile Platform

    In order to to enable Realm Mobile Platform you must add the following section to your app’s build.gradle:

    realm {
        syncEnabled = true;
    }