Adding Realm to your project
suggest changeAdd the plugin to the buildscript block of the project-level build.gradle. classpath is not a normal module dependency.
buildscript {
dependencies {
classpath "io.realm:realm-gradle-plugin:3.1.2"
}
}
Add the following right at the top of your app level build.gradle file.
apply plugin: 'realm-android'
Sync Gradle. Realm is then available to the module.
Since Realm 2.0.0 you must initialize it before use, in your Application class or in the first activity’s onCreate:
Realm.init(this); // added in Realm 2.0.0
Realm.setDefaultConfiguration(new RealmConfiguration.Builder().build());
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents