onseok / peekaboo

🌄 Kotlin Multiplatform library for Compose Multiplatform, designed for seamless integration of an image picker feature in iOS and Android applications.
Apache License 2.0
237 stars 20 forks source link

Whenever i run the ImagePicker after selecting the desired image i get this error #57

Closed kwesiamartey closed 8 months ago

kwesiamartey commented 9 months ago

java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = uiComponent.UploadCompanyDocument)

onseok commented 9 months ago

Hi @kwesiamartey, could you provide a smaller reproducer?

kwesiamartey commented 8 months ago

Hi @onseok find the reproducer below

    val multipleImagePicker =
        rememberImagePickerLauncher(
            selectionMode = SelectionMode.Multiple(maxSelection = 2),
            scope = scope,
            // Resize options are customizable. Default is set to 800 x 800 pixels.
            resizeOptions = ResizeOptions(width = 400, height = 400),
            onResult = { byteArrays ->
                try {
                    images = byteArrays.map { byteArray ->
                        byteArray.toImageBitmap()
                    }
                    byteArrays.onEach {

                    }

                    companyFile.add(
                        CompanyFile(
                            fileData = byteArrays[0],
                            fileExt = "jpg",
                            fileName = "ID Document"
                        )
                    )

                } catch (e: Exception) {
                    // Log or print the exception information
                    e.printStackTrace()
                }
            },
        )
onseok commented 8 months ago

Hi @kwesiamartey, it looks like the issue you're facing with the Parcelable encountered IOException error isn't related to the peekaboo-image-picker module. Instead, the problem seems to stem from how the object is being serialized. I'd recommend double-checking that CompanyFile or something else.

kwesiamartey commented 8 months ago

@onseok this is a reproducer of CompanyFile

@Serializable data class CompanyFile( @SerialName("file_data") var fileData: ByteArray?=null, @SerialName("file_ext") var fileExt: String? = null, @SerialName("file_name") var fileName: String? = null )