【问题标题】:I got " Error Unable to invoke no-args constructor for class CLASSNAME" with Parcalize我用 Parcalize 得到“错误无法为类 CLASSNAME 调用无参数构造函数”
【发布时间】:2020-06-04 00:09:28
【问题描述】:

我正在使用 @Parcelize 用 kotlin 创建 parcable 模型

@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】:

在 Gradle 中输入这个

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

apply plugin: "kotlin-noarg"

【讨论】:

  • 能否请您提供问题所在、原因以及您认为您的答案会解决问题的原因?
猜你喜欢
  • 2022-12-05
  • 2015-08-02
  • 2019-10-19
  • 2023-03-07
  • 2019-05-07
  • 2020-02-14
  • 2015-06-27
  • 2020-06-15
  • 1970-01-01
相关资源
最近更新 更多