用Parcalize出现“ Error无法为类CLASSNAME调用no-args构造函数”

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

我正在使用@ Parcelize与kotlin创建可解析模型

@Parcelize
data class GymPackage(
    val id: Int?,
    val name: String?,
    val description: String?,
    val price: Int?,
    val duration: Int?,
    @SerializedName("discount_precentage")
    val discountPrecentage: Int?,
    @SerializedName("price_after_discount")
    val priceAfterDiscount: Double?,
    @SerializedName("gym_id")
    val gymId: Int?

) : Parcelable

我收到此错误Error Unable to invoke no-args constructor for class com.inova.algym.datalayer.remote.responses.GymPackage. Registering an InstanceCreator with Gson for this type may fix this problem.

koltin版本:: 1.3.61

尝试过但未解决问题

android kotlin parcelable
1个回答
0
投票
在Gradle中输入此内容

buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version" } } apply plugin: "kotlin-noarg"

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