when i use kotlin-parcelize in my application,after i build my project ,i get a error : can't find symbol readFromParcel

72 Views Asked by At

when i use kotlin-parcelize in my application,after i build my project ,i get a error : can't find symbol readFromParcel. this is my BtDevice kotlin file :

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class BtDevice(var address: String = "") : Parcelable

this is BtDevice aidl file;

parcelable  BtDevice;

this is where it used,in another aidl interface .

 interface  DeviceFoundListener{
    void onDeviceFound(inout BtDevice device);
    void bondSuccess(inout BtDevice device);
}

i already add this gradle config

plugins {
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-parcelize'
}

what should i do ?

i already find this page :https://developer.android.com/kotlin/parcelize but i can't get help .

1

There are 1 best solutions below

0
NaughtyChild On

i find after add this function manually ,it's ok


@Parcelize
data class BtDevice(var address: String = "",var name:String="") : Parcelable{
    fun readFromParcel(parcel: Parcel) {
        address = parcel.readString()!!
        name = parcel.readString()!!
    }
}