Murad Ismayilov
Murad Ismayilov

Reputation: 57

Parcel: unable to marshal value com.google.firebase.firestore.DocumentReference

I store a list of references in the Cloud Firestore. When I get the data I it gives me this error:

"java.lang.RuntimeException: Parcel: unable to marshal value com.google.firebase.firestore.DocumentReference@44bef898"

I've searched on the internet but didn't find any solution. Thank you in advance

User.kt

import android.os.Parcelable
import com.google.firebase.firestore.DocumentReference
import kotlinx.android.parcel.Parcelize
import kotlinx.android.parcel.RawValue

@Parcelize
data class User(
    val bio: String? = null,
    val email: String? = null,
    val followers: @RawValue List<DocumentReference>? = null,
    val following: @RawValue List<DocumentReference>? = null,
    val picture: String? = null,
    val uid: String? = null,
    val username: String? = null
) : Parcelable

Upvotes: 0

Views: 564

Answers (1)

Alex Mamo
Alex Mamo

Reputation: 138899

You are getting the following error:

"java.lang.RuntimeException: Parcel: unable to marshal value com.google.firebase.firestore.DocumentReference

Because your User class implements Parcelable, and all the fields inside it should also implement Parcelable, which doesn't, since both properties followers and following, are of type List<DocumentReference> and DocumentReference does not implement Parcelable, nor Serializable. To solve this, you should check my answer from the following post:

And use the String path that exists in each DocumentReference object.

Upvotes: 1

Related Questions