1

I am using Parcelize in kotlin.

Whenever I run my app on an API level below 21 I get the following exceptions:

W/dalvikvm: VFY: register1 v5 type 17, wanted 5
W/dalvikvm: VFY: register1 v6 type 17, wanted 5
W/dalvikvm: VFY:  rejecting opcode 0x76 at 0x0020
W/dalvikvm: VFY:  rejected L$Creator;.createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object;
W/dalvikvm: Verifier rejected class L$Creator;
W/dalvikvm: Exception Ljava/lang/VerifyError; thrown while initializing L/data/model/Student;
: Unable to invoke no-args constructor for class data.model.Student. Registering an InstanceCreator with Gson for this type may fix this problem.
I/dalvikvm: Rejecting re-init on previously-failed class L/data/model/Student; v=0x0
I/dalvikvm: Rejecting re-init on previously-failed class L/data/model/Student; v=0x0
W/dalvikvm: VFY: unable to find class referenced in signature (L/data/model/Student;)

I've tried using classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version" and apply plugin: "kotlin-noarg" but with no luck.

 @Parcelize
@Entity(tableName = Constants.STUDENTS_TABLE_NAME)
data class Student(
        @PrimaryKey
        @ColumnInfo(name = "name")
        @SerializedName("name")
        val name: String,
        @ColumnInfo(name = "phone")
        @SerializedName("phone")
        val phone: String,
        @ColumnInfo(name = "address")
        @SerializedName("address")
        val address: String,
        @ColumnInfo(name = "city")
        @SerializedName("city")
        val city: String,
        @ColumnInfo(name = "sponsored")
        @SerializedName("sponsored")
        val isSponsored: Boolean,
        @ColumnInfo(name = "isFavorite")
        var isFavorite: Boolean

) : Parcelable

And this is the only code for Gson

 @Provides
@Singleton
fun provideGson(): Gson {
    return GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
}
Eugen Pechanec
  • 37,669
  • 7
  • 103
  • 124
jlively
  • 735
  • 2
  • 9
  • 29
  • You should also add the code which troubles you. In this case `Student`. Also it looks like it's an issue with `Gson` and not `Parcelize`. – tynn Jan 06 '18 at 18:02
  • @tynn I've edited my question. – jlively Jan 06 '18 at 18:41
  • Gson throw this exception if you put incorrect class when passing. Check this answer, I think it same with yours https://stackoverflow.com/a/30372271/1983018 .Agree with @tynn that this is `Gson` issue instead of `Parcelize` – cuasodayleo Nov 23 '18 at 10:24

0 Answers0