将RealmObject类转换为Kotlin时编译时错误
这是我的原始RealmObject
Parceler
注释。
@Parcel(implementations = {AlbumRealmProxy.class}, value = Parcel.Serialization.BEAN, analyze = {Album.class}) public class Album extends RealmObject { @PrimaryKey @SerializedName("id") private String id; @SerializedName("artist_id") private String artistId; @SerializedName("title") private String title; @SerializedName("artist_name") private String artist; @SerializedName("images") private RealmList artwork; @SerializedName("tracks") private RealmList
在转换到Kotlin
我得到以下生成的类;
@Parcel(implementations = arrayOf(AlbumRealmProxy::class), value = Parcel.Serialization.BEAN, analyze = arrayOf(Album::class)) open class Album : RealmObject() { @PrimaryKey @SerializedName("id") var id: String? = null @SerializedName("artist_id") val artistId: String? = null @SerializedName("title") var title: String? = null @SerializedName("artist_name") var artist: String? = null @SerializedName("images") @set:ParcelPropertyConverter(RealmListParcelConverter::class) open var artwork: RealmList? = null @SerializedName("tracks") @set:ParcelPropertyConverter(RealmListParcelConverter::class) open var tracks: RealmList? = null @SerializedName("artist_bio") val artistBio: String? = null }
编译时错误如下:
Error:(5, 17) Unresolved reference: AlbumRealmProxy Error:(16, 27) Only 'const val' can be used in constant expressions Error:(16, 35) Unresolved reference: AlbumRealmProxy Error:(16, 35) An annotation parameter must be a compile-time constant [KOTLIN] deleting /Users/dev/RAG Apps/Songa/app/build/tmp/kotlin-classes/debug on error [KOTLIN] deleting /Users/dev/RAG Apps/Songa/app/build/tmp/kotlin-classes/debug on error
我为Parceler
使用Kotlin kapt
注释处理器,但是该项目仍然不能编译。
是否需要一些额外的配置?