@JsonClass can't be applied to [class], RealmObject is not Kotlin typepublic

问题描述 投票:0回答:1

i bumped on a problem with setting up my Realm instances with Moshi annotations. Haven't found any similar problems.

Model classes below

FormField.kt

@JsonClass(generateAdapter = true)
open class FormField(

    @Json(name="fieldId")
    private var fieldId: String? = null,
    @Json(name="fieldName")
    private var fieldName: String? = null,
    @Json(name="fieldType")
    private var fieldType: String? = null,
    @Json(name="isRequired")
    private var isRequired: Boolean? = null
): RealmObject()

Form.kt @JsonClass(generateAdapter = true) open class Form(

    @Json(name="data")
    private var formFields: RealmList<FormField>? = null,
    @Json(name="name")
    private var name: Boolean? = null,
    @Json(name="description")
    private var description: Boolean? = null,
    @Json(name="error")
    private var error: Boolean? = null,
    @Json(name="message")
    private var message: String? = null,
    @Json(name="status")
    private var status: String? = null
): RealmObject()

And errors im receiving

@JsonClass can't be applied to com.example.dynamicforms.data.entity.Form: supertype io.realm.RealmObject is not a Kotlin type
public class Form extends io.realm.RealmObject {
       ^

@JsonClass can't be applied to com.example.dynamicforms.data.entity.FormField: supertype io.realm.RealmObject is not a Kotlin type
public class FormField extends io.realm.RealmObject {
       ^

Thanks in advance for any help :)

android json kotlin realm moshi
1个回答
0
投票

Code compiles after deleting @JsonClass(generateAdapter = true), but isn't it harm since im removing my adapter. For what i know it was taking care of reflection. Hopefully it won't be problem in future.

© www.soinside.com 2019 - 2024. All rights reserved.