Reputation: 152
FATAL EXCEPTION: main
java.lang.IllegalArgumentException:
student_relam_pojo is not part of the schema for this Realm at io.realm.internal.modules.CompositeMediator.getMediator(CompositeMediator.java:118) at io.realm.internal.modules.CompositeMediator.getTableName(CompositeMediator.java:71) at io.realm.Realm.getTable(Realm.java:327)
at io.realm.Realm.createObject(Realm.java:1085)at example.com.kotlinexamplebydimple.RealmActivity$onCreate$1.onClick(RealmActivity.kt:24)
val realm = Realm.getInstance(this@RealmActivity)
btn_click.setOnClickListener {
realm.beginTransaction()
var pojo : student_relam_pojo ?
pojo = realm.createObject(student_relam_pojo::class.java)
pojo.nm = edt_name.text.toString()
pojo.pass = edt_pass.text.toString()
realm.commitTransaction()
}
Student_realm_pojo
public open class student_relam_pojo() : RealmObject()
{
public open var nm : String ?= null
public open var pass : String ?= null
}
Upvotes: 2
Views: 694
Reputation: 81529
1.) You should use at least Realm 2.3.0 for reliably using KAPT
2.) your plugin order should look like this:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
3.) if you are using RealmObjects defined in a library module, you need to explicitly specify them in the RealmConfiguration using @RealmModule
s, see here.
4.) you might have added this class without providing a migration for it. Consider either providing a migration, or setting deleteIfMigrationNeeded()
.
Upvotes: 2