Skip to content
Advertisement

java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = [[Landroid.widget.Button;)

I am coding a sudoku solver app. However it keeps crashing for some unknown reason.

When I try to debug the app, I don’t get a specific line that tells me what it is in my code that makes it crash. However, I see that it goes through the entire solverActivity class without crashing and shows the correct suoku board for about half a second then it crashes.

I have interpreted the error message as if im trying to send an object (Button) that is not serializable. However, I do not find in my code where I try to do that.

I have googled but have not found any solution that has helped me. Which has led me to write this post.

Here is the stacktrace.

2020-03-08 09:40:19.559 15499-15499/com.example.sodukosolver E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.sodukosolver, PID: 15499 java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = [[Landroid.widget.Button;) at android.os.Parcel.writeSerializable(Parcel.java:1833) at android.os.Parcel.writeValue(Parcel.java:1780) at android.os.Parcel.writeArrayMapInternal(Parcel.java:928) at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1584) at android.os.Bundle.writeToParcel(Bundle.java:1253) at android.app.IActivityTaskManager$Stub$Proxy.activityStopped(IActivityTaskManager.java:4505) at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:145) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) Caused by: java.io.NotSerializableException: androidx.appcompat.widget.AppCompatButton at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1240) at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1434) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1230) at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1434) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1230) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:354) at android.os.Parcel.writeSerializable(Parcel.java:1828) at android.os.Parcel.writeValue(Parcel.java:1780)  at android.os.Parcel.writeArrayMapInternal(Parcel.java:928)  at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1584)  at android.os.Bundle.writeToParcel(Bundle.java:1253)  at android.app.IActivityTaskManager$Stub$Proxy.activityStopped(IActivityTaskManager.java:4505)  at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:145)  at android.os.Handler.handleCallback(Handler.java:883)  at android.os.Handler.dispatchMessage(Handler.java:100)  at android.os.Looper.loop(Looper.java:214)  at android.app.ActivityThread.main(ActivityThread.java:7356)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 

Here is my MainActivity which I think works fine (Sorry for not following CLEAN CODE :/ ).

JavaScript

Here is my SolverActivity which i think is causing the problem (Sorry for the long onCreate, im planning on refactoring the class after i get this solved).

JavaScript

Advertisement

Answer

I found what was caused my app to crash, and I wanted to share my solution if someone else might have an similar problem.

JavaScript

I don’t even know, why I had these to begin with since the where not used. Anyway since i did not need them is simply deleted the two lines, making it look like this.

JavaScript

I think what caused the problem was saving the 2D Array of buttons in this manner. For people that have similar problem I would recommend that look over how you save in OnsaveInstanceState.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement