【发布时间】:2018-05-11 13:49:57
【问题描述】:
我有一节这样的公开课
open class NewsResponse(
@field:SerializedName("news")
val news: List<NewsItem?>? = null
):RealmObject()
NewsItem 类是这样的
open class NewsItem(
@field:SerializedName("created")
val created: String? = null,
@field:SerializedName("link")
val link: String? = null,
@field:SerializedName("description")
val description: String? = null,
@field:SerializedName("title")
val title: String? = null
):RealmObject()
我也加了
apply plugin: 'com.android.application'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android-extensions'
app gradle 中的这些插件
我在项目级别的 gradle 中有 classpath "io.realm:realm-gradle-plugin:5.1.0"。
所以当我运行应用程序时,我得到一个错误提示
Caused by: io.realm.exceptions.RealmException: NewsItem is not part of the schema for this Realm
at io.realm.internal.modules.CompositeMediator.getMediator(CompositeMediator.java:180)
如何解决这个问题?
【问题讨论】:
标签: android kotlin realm kotlin-android-extensions android-ktx