I am trying to download an object from the firebase firestore database and send it to an other activity. Here is my code:
FirebaseFirestore.getInstance().collection(Constants.COLLECTION)
                        .document(getCurrentUid()!!)
                        .get()
                        .addOnSuccessListener {
                            snapshot ->
                            val user: User? = snapshot.toObject(User::class.java)
                            val intent = Intent(this, MainActivity::class.java)
                            intent.putExtra(Constants.USER_OBJECT, user)
                        }
but the problem is I am getting an error in intent.putExtra(Constants.USER_OBJECT, user).
My User class implements serializable
What is wrong here?
 
    