我有一个这样的公开课
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'应用程序级中的这些插件
我在项目级别级别有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)如何解决这个问题?
发布于 2018-05-11 13:52:10
使用此命令:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
apply plugin: 'io.fabric'发布于 2018-10-04 03:50:37
对我来说,我必须改变我的命令:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'kotlin-android'并在我的模型类中添加一个空构造函数。
https://stackoverflow.com/questions/50293840
复制相似问题