A screen with timer running crashes app when minim...
# compose
p
A screen with timer running crashes app when minimised. How to prevent it ?
j
There is not enough information provided for anyone to be able to give advice. Is this on iOS or Android? Crash stacktrace. Maybe some code of your screen containing your time (or minimum reproducible sample).
p
My bad. I thought it was not allowed by design.
Testing on android. Getting error: ``FATAL EXCEPTION: main (Fix with AI)`
Process: com. PID: 5345
android.os.BadParcelableException: Parcelable encountered IOException writing serializable object (name = com...screens.TestScreen)
at android.os.Parcel.writeSerializable(Parcel.java:3094)
at android.os.Parcel.writeValue(Parcel.java:2860)
Caused by: java.io.NotSerializableException: com.kricq.android.models.Question
at <http://java.io|java.io>.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1240)
j
Can you paste your entire
Questions
class?
p
Copy code
import kotlinx.serialization.Serializable

@Serializable
data class Question(
    val id: String = "",
    val question: String = "",
    val options: List<String> = emptyList(),
    val accepted: String = "",
    val level: Int = 1,
    val num: Int = 0
)
j
Try wrapping your stacktrace in triple backticks `````
p
I was trying.. it is breaking on newline
j
Copy code
FATAL EXCEPTION: main (Fix with AI)
                                                                                                    Process: com. PID: 5345
                                                                                                    android.os.BadParcelableException: Parcelable encountered IOException writing serializable object (name = com...screens.TestScreen)
                                                                                                    	at android.os.Parcel.writeSerializable(Parcel.java:3094)
                                                                                                    	at android.os.Parcel.writeValue(Parcel.java:2860)

Caused by: java.io.NotSerializableException: com.kricq.android.models.Question
                                                                                                    	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1240)
You correctly are applying the
@Serializable
annotation. Did you also apply the serializable plugin?
p
in composeApp/build.gradle
Copy code
plugins {

...

alias(libs.plugins.kotlinSerialization)

}
try narrow it down to a MCVE and you will find the issue. https://blog.jooq.org/how-to-create-a-good-mcve-minimal-complete-verifiable-example/