New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caused by: java.io.NotSerializableException #1903

Closed
osayilgan opened this Issue Dec 7, 2015 · 17 comments

Comments

Projects
None yet
@osayilgan

osayilgan commented Dec 7, 2015

Hi there,

Since I've upgraded Realm from 0.82 to 0.84 (and also to 0.85, 0.86) I started getting this exception. I've that Realm Object in a Fragment and when I push the App to background with Home button, App Crashes.

Here is the Full Stack Trace.

Caused by: java.io.NotSerializableException: io.realm.PrinterRealmProxy$PrinterColumnInfo at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344) at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461) at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959) at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360) at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054) at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384) at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461) at android.os.Parcel.writeSerializable(Parcel.java:1442) at android.os.Parcel.writeValue(Parcel.java:1395)  at android.os.Parcel.writeArrayMapInternal(Parcel.java:665)  at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)  at android.os.Bundle.writeToParcel(Bundle.java:1079)  at android.os.Parcel.writeBundle(Parcel.java:690)  at android.app.FragmentState.writeToParcel(Fragment.java:140)  at android.os.Parcel.writeTypedArray(Parcel.java:1233)  at android.app.FragmentManagerState.writeToParcel(FragmentManager.java:380)  at android.os.Parcel.writeParcelable(Parcel.java:1416)  at android.os.Parcel.writeValue(Parcel.java:1322)  at android.os.Parcel.writeArrayMapInternal(Parcel.java:665)  at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)  at android.os.Bundle.writeToParcel(Bundle.java:1079)  at android.os.Parcel.writeBundle(Parcel.java:690)  at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3152)  at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3417)  at android.os.Handler.handleCallback(Handler.java:739)  at android.os.Handler.dispatchMessage(Handler.java:95)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)

@saket

This comment has been minimized.

Show comment
Hide comment
@saket

saket Dec 8, 2015

Are you trying to serialize your RealmObject?

saket commented Dec 8, 2015

Are you trying to serialize your RealmObject?

@osayilgan

This comment has been minimized.

Show comment
Hide comment
@osayilgan

osayilgan Dec 8, 2015

@Saketme No, not really. It's probably the Fragment trying to save it's state. I'm not trying to serialize the Realm Object myself.

osayilgan commented Dec 8, 2015

@Saketme No, not really. It's probably the Fragment trying to save it's state. I'm not trying to serialize the Realm Object myself.

@cmelchior

This comment has been minimized.

Show comment
Hide comment
@cmelchior

cmelchior Dec 8, 2015

Contributor

@osayilgan Are you saving your RealmObject in a Parcel or Bundle? It looks like Android is trying to write it to disk which fails. One work-around is to save the PrimaryKey in the Parcel instead and then query for the object if needed.

If that is not the case. Can you post the content of your Fragment class?

Contributor

cmelchior commented Dec 8, 2015

@osayilgan Are you saving your RealmObject in a Parcel or Bundle? It looks like Android is trying to write it to disk which fails. One work-around is to save the PrimaryKey in the Parcel instead and then query for the object if needed.

If that is not the case. Can you post the content of your Fragment class?

@osayilgan

This comment has been minimized.

Show comment
Hide comment
@osayilgan

osayilgan Dec 8, 2015

@cmelchior So, there are 3 parts of that process. Activity, Fragment and a Service. First, Activity creates the Fragment with extras (including a Realm Object), Fragment gets this extras Bundle with getArguments() and starts a service. Later, fragment sends this extra data to Service within a Message Object.

At the moment, according to my Synchronisation architecture, I cannot just store the Primary Key of Realm Object and query it later from database. I've to keep that Object in my background Service.

It's been working for all that time, until I upgraded Realm from 0.82 to newest version. It started throwing this exception. I'm wondering what is that change causing this exception.

osayilgan commented Dec 8, 2015

@cmelchior So, there are 3 parts of that process. Activity, Fragment and a Service. First, Activity creates the Fragment with extras (including a Realm Object), Fragment gets this extras Bundle with getArguments() and starts a service. Later, fragment sends this extra data to Service within a Message Object.

At the moment, according to my Synchronisation architecture, I cannot just store the Primary Key of Realm Object and query it later from database. I've to keep that Object in my background Service.

It's been working for all that time, until I upgraded Realm from 0.82 to newest version. It started throwing this exception. I'm wondering what is that change causing this exception.

@kneth kneth removed the Pending label Dec 10, 2015

@cmelchior

This comment has been minimized.

Show comment
Hide comment
@cmelchior

cmelchior Dec 11, 2015

Contributor

Persisted realmObjects are really not intended to be serialised, and I am guessing that it was mostly by accident it worked before.

Between 0.82.1 and 0.86 we changed some of the internals of our Proxy classes and I expect those changes are incompatible with how you serialize the data.

We have added functionality in 0.87.0 that allows you to get a copy of the Realm data (effectively serializing it) using realm.copyFromRealm() which I think will suit your use case . Until that is released the work-around would be to copy the data you want manually into a standalone object.

Contributor

cmelchior commented Dec 11, 2015

Persisted realmObjects are really not intended to be serialised, and I am guessing that it was mostly by accident it worked before.

Between 0.82.1 and 0.86 we changed some of the internals of our Proxy classes and I expect those changes are incompatible with how you serialize the data.

We have added functionality in 0.87.0 that allows you to get a copy of the Realm data (effectively serializing it) using realm.copyFromRealm() which I think will suit your use case . Until that is released the work-around would be to copy the data you want manually into a standalone object.

@cmelchior cmelchior added the Pending label Dec 11, 2015

@tarigancana

This comment has been minimized.

Show comment
Hide comment
@tarigancana

tarigancana Dec 12, 2015

Hi i get this error too 👍


FATAL EXCEPTION: main

                                                                      java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = io.realm.SermonRealmProxy)
                                                                          at android.os.Parcel.writeSerializable(Parcel.java:1447)
                                                                          at android.os.Parcel.writeValue(Parcel.java:1395)
                                                                          at android.os.Parcel.writeArrayMapInternal(Parcel.java:665)
                                                                          at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)
                                                                          at android.os.Bundle.writeToParcel(Bundle.java:1079)
                                                                          at android.os.Parcel.writeBundle(Parcel.java:690)
                                                                          at android.content.Intent.writeToParcel(Intent.java:7793)
                                                                          at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2639)
                                                                          at android.app.Instrumentation.execStartActivity(Instrumentation.java:1507)
                                                                          at android.app.Activity.startActivityForResult(Activity.java:3917)
                                                                          at android.app.Activity.startActivityForResult(Activity.java:3877)
                                                                          at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:784)
                                                                          at android.app.Activity.startActivity(Activity.java:4200)
                                                                          at android.app.Activity.startActivity(Activity.java:4168)
                                                                          at co.rtlabs.khotbahorg.ui.adapter.SermonListAdapter$1.onClick(SermonListAdapter.java:53)
                                                                          at android.view.View.performClick(View.java:5198)
                                                                          at android.view.View$PerformClick.run(View.java:21147)
                                                                          at android.os.Handler.handleCallback(Handler.java:739)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                          at android.os.Looper.loop(Looper.java:148)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                       Caused by: java.io.NotSerializableException: io.realm.SermonRealmProxy$SermonColumnInfo
                                                                          at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344)
                                                                          at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                          at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
                                                                          at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
                                                                          at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
                                                                          at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
                                                                          at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                          at android.os.Parcel.writeSerializable(Parcel.java:1442)
                                                                          at android.os.Parcel.writeValue(Parcel.java:1395) 
                                                                          at android.os.Parcel.writeArrayMapInternal(Parcel.java:665) 
                                                                          at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330) 
                                                                          at android.os.Bundle.writeToParcel(Bundle.java:1079) 
                                                                          at android.os.Parcel.writeBundle(Parcel.java:690) 
                                                                          at android.content.Intent.writeToParcel(Intent.java:7793) 
                                                                          at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2639) 
                                                                          at android.app.Instrumentation.execStartActivity(Instrumentation.java:1507) 
                                                                          at android.app.Activity.startActivityForResult(Activity.java:3917) 
                                                                          at android.app.Activity.startActivityForResult(Activity.java:3877) 
                                                                          at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:784) 
                                                                          at android.app.Activity.startActivity(Activity.java:4200) 
                                                                          at android.app.Activity.startActivity(Activity.java:4168) 
                                                                          at co.rtlabs.khotbahorg.ui.adapter.SermonListAdapter$1.onClick(SermonListAdapter.java:53) 
                                                                          at android.view.View.performClick(View.java:5198) 
                                                                          at android.view.View$PerformClick.run(View.java:21147) 
                                                                          at android.os.Handler.handleCallback(Handler.java:739) 
                                                                          at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                          at android.os.Looper.loop(Looper.java:148) 
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                          at java.lang.reflect.Method.invoke(Native Method) 
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

this is the flow of my data :

1. copyorupdaterealm(sermonObject)
2. query the data to get the sermonObject and show to the list
3. put the sermonObject to intent using putExtra

any suggestion ?
I'm using Realm 0.86.1
And i have the class to extends RealmObject and implements Serializeable and put a primarykey there.

tarigancana commented Dec 12, 2015

Hi i get this error too 👍


FATAL EXCEPTION: main

                                                                      java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = io.realm.SermonRealmProxy)
                                                                          at android.os.Parcel.writeSerializable(Parcel.java:1447)
                                                                          at android.os.Parcel.writeValue(Parcel.java:1395)
                                                                          at android.os.Parcel.writeArrayMapInternal(Parcel.java:665)
                                                                          at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)
                                                                          at android.os.Bundle.writeToParcel(Bundle.java:1079)
                                                                          at android.os.Parcel.writeBundle(Parcel.java:690)
                                                                          at android.content.Intent.writeToParcel(Intent.java:7793)
                                                                          at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2639)
                                                                          at android.app.Instrumentation.execStartActivity(Instrumentation.java:1507)
                                                                          at android.app.Activity.startActivityForResult(Activity.java:3917)
                                                                          at android.app.Activity.startActivityForResult(Activity.java:3877)
                                                                          at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:784)
                                                                          at android.app.Activity.startActivity(Activity.java:4200)
                                                                          at android.app.Activity.startActivity(Activity.java:4168)
                                                                          at co.rtlabs.khotbahorg.ui.adapter.SermonListAdapter$1.onClick(SermonListAdapter.java:53)
                                                                          at android.view.View.performClick(View.java:5198)
                                                                          at android.view.View$PerformClick.run(View.java:21147)
                                                                          at android.os.Handler.handleCallback(Handler.java:739)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                          at android.os.Looper.loop(Looper.java:148)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                       Caused by: java.io.NotSerializableException: io.realm.SermonRealmProxy$SermonColumnInfo
                                                                          at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344)
                                                                          at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                          at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
                                                                          at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
                                                                          at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
                                                                          at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
                                                                          at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                          at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                          at android.os.Parcel.writeSerializable(Parcel.java:1442)
                                                                          at android.os.Parcel.writeValue(Parcel.java:1395) 
                                                                          at android.os.Parcel.writeArrayMapInternal(Parcel.java:665) 
                                                                          at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330) 
                                                                          at android.os.Bundle.writeToParcel(Bundle.java:1079) 
                                                                          at android.os.Parcel.writeBundle(Parcel.java:690) 
                                                                          at android.content.Intent.writeToParcel(Intent.java:7793) 
                                                                          at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2639) 
                                                                          at android.app.Instrumentation.execStartActivity(Instrumentation.java:1507) 
                                                                          at android.app.Activity.startActivityForResult(Activity.java:3917) 
                                                                          at android.app.Activity.startActivityForResult(Activity.java:3877) 
                                                                          at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:784) 
                                                                          at android.app.Activity.startActivity(Activity.java:4200) 
                                                                          at android.app.Activity.startActivity(Activity.java:4168) 
                                                                          at co.rtlabs.khotbahorg.ui.adapter.SermonListAdapter$1.onClick(SermonListAdapter.java:53) 
                                                                          at android.view.View.performClick(View.java:5198) 
                                                                          at android.view.View$PerformClick.run(View.java:21147) 
                                                                          at android.os.Handler.handleCallback(Handler.java:739) 
                                                                          at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                          at android.os.Looper.loop(Looper.java:148) 
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                          at java.lang.reflect.Method.invoke(Native Method) 
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

this is the flow of my data :

1. copyorupdaterealm(sermonObject)
2. query the data to get the sermonObject and show to the list
3. put the sermonObject to intent using putExtra

any suggestion ?
I'm using Realm 0.86.1
And i have the class to extends RealmObject and implements Serializeable and put a primarykey there.

@osayilgan

This comment has been minimized.

Show comment
Hide comment
@osayilgan

osayilgan Dec 15, 2015

@cmelchior Thanks. I guess I will wait for the next release, so I can serialise the persisted object.

osayilgan commented Dec 15, 2015

@cmelchior Thanks. I guess I will wait for the next release, so I can serialise the persisted object.

@kneth kneth added the Pending label Dec 16, 2015

@Kml55

This comment has been minimized.

Show comment
Hide comment
@Kml55

Kml55 Dec 16, 2015

Same problem when home button pressed

Realm version : 0.85.1

java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = io.realm.ProductRealmProxy)
                                                                        at android.os.Parcel.writeSerializable(Parcel.java:1468)
                                                                        at android.os.Parcel.writeValue(Parcel.java:1416)
                                                                        at android.os.Parcel.writeArrayMapInternal(Parcel.java:686)
                                                                        at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)
                                                                        at android.os.Bundle.writeToParcel(Bundle.java:1079)
                                                                        at android.os.Parcel.writeBundle(Parcel.java:711)
                                                                        at android.support.v4.app.FragmentState.writeToParcel(Fragment.java:137)
                                                                        at android.os.Parcel.writeTypedArray(Parcel.java:1254)
                                                                        at android.support.v4.app.FragmentManagerState.writeToParcel(FragmentManager.java:385)
                                                                        at android.os.Parcel.writeParcelable(Parcel.java:1437)
                                                                        at android.os.Parcel.writeValue(Parcel.java:1343)
                                                                        at android.os.Parcel.writeArrayMapInternal(Parcel.java:686)
                                                                        at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)
                                                                        at android.os.Bundle.writeToParcel(Bundle.java:1079)
                                                                        at android.os.Parcel.writeBundle(Parcel.java:711)
                                                                        at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3152)
                                                                        at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3417)
                                                                        at android.os.Handler.handleCallback(Handler.java:739)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                        at android.os.Looper.loop(Looper.java:148)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                     Caused by: java.io.NotSerializableException: io.realm.ProductRealmProxy$ProductColumnInfo
                                                                        at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344)
                                                                        at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                        at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
                                                                        at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
                                                                        at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
                                                                        at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
                                                                        at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                        at android.os.Parcel.writeSerializable(Parcel.java:1463)
                                                                        at android.os.Parcel.writeValue(Parcel.java:1416) 
                                                                        at android.os.Parcel.writeArrayMapInternal(Parcel.java:686) 
                                                                        at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330) 
                                                                        at android.os.Bundle.writeToParcel(Bundle.java:1079) 
                                                                        at android.os.Parcel.writeBundle(Parcel.java:711) 
                                                                        at android.support.v4.app.FragmentState.writeToParcel(Fragment.java:137) 
                                                                        at android.os.Parcel.writeTypedArray(Parcel.java:1254) 
                                                                        at android.support.v4.app.FragmentManagerState.writeToParcel(FragmentManager.java:385) 
                                                                        at android.os.Parcel.writeParcelable(Parcel.java:1437) 
                                                                        at android.os.Parcel.writeValue(Parcel.java:1343) 
                                                                        at android.os.Parcel.writeArrayMapInternal(Parcel.java:686) 
                                                                        at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330) 
                                                                        at android.os.Bundle.writeToParcel(Bundle.java:1079) 
                                                                        at android.os.Parcel.writeBundle(Parcel.java:711) 
                                                                        at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3152) 
                                                                        at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3417) 
                                                                        at android.os.Handler.handleCallback(Handler.java:739) 
                                                                        at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                        at android.os.Looper.loop(Looper.java:148) 
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

Kml55 commented Dec 16, 2015

Same problem when home button pressed

Realm version : 0.85.1

java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = io.realm.ProductRealmProxy)
                                                                        at android.os.Parcel.writeSerializable(Parcel.java:1468)
                                                                        at android.os.Parcel.writeValue(Parcel.java:1416)
                                                                        at android.os.Parcel.writeArrayMapInternal(Parcel.java:686)
                                                                        at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)
                                                                        at android.os.Bundle.writeToParcel(Bundle.java:1079)
                                                                        at android.os.Parcel.writeBundle(Parcel.java:711)
                                                                        at android.support.v4.app.FragmentState.writeToParcel(Fragment.java:137)
                                                                        at android.os.Parcel.writeTypedArray(Parcel.java:1254)
                                                                        at android.support.v4.app.FragmentManagerState.writeToParcel(FragmentManager.java:385)
                                                                        at android.os.Parcel.writeParcelable(Parcel.java:1437)
                                                                        at android.os.Parcel.writeValue(Parcel.java:1343)
                                                                        at android.os.Parcel.writeArrayMapInternal(Parcel.java:686)
                                                                        at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)
                                                                        at android.os.Bundle.writeToParcel(Bundle.java:1079)
                                                                        at android.os.Parcel.writeBundle(Parcel.java:711)
                                                                        at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3152)
                                                                        at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3417)
                                                                        at android.os.Handler.handleCallback(Handler.java:739)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                        at android.os.Looper.loop(Looper.java:148)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                     Caused by: java.io.NotSerializableException: io.realm.ProductRealmProxy$ProductColumnInfo
                                                                        at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344)
                                                                        at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                        at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
                                                                        at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
                                                                        at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
                                                                        at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
                                                                        at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                        at android.os.Parcel.writeSerializable(Parcel.java:1463)
                                                                        at android.os.Parcel.writeValue(Parcel.java:1416) 
                                                                        at android.os.Parcel.writeArrayMapInternal(Parcel.java:686) 
                                                                        at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330) 
                                                                        at android.os.Bundle.writeToParcel(Bundle.java:1079) 
                                                                        at android.os.Parcel.writeBundle(Parcel.java:711) 
                                                                        at android.support.v4.app.FragmentState.writeToParcel(Fragment.java:137) 
                                                                        at android.os.Parcel.writeTypedArray(Parcel.java:1254) 
                                                                        at android.support.v4.app.FragmentManagerState.writeToParcel(FragmentManager.java:385) 
                                                                        at android.os.Parcel.writeParcelable(Parcel.java:1437) 
                                                                        at android.os.Parcel.writeValue(Parcel.java:1343) 
                                                                        at android.os.Parcel.writeArrayMapInternal(Parcel.java:686) 
                                                                        at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330) 
                                                                        at android.os.Bundle.writeToParcel(Bundle.java:1079) 
                                                                        at android.os.Parcel.writeBundle(Parcel.java:711) 
                                                                        at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3152) 
                                                                        at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3417) 
                                                                        at android.os.Handler.handleCallback(Handler.java:739) 
                                                                        at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                        at android.os.Looper.loop(Looper.java:148) 
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
@kneth

This comment has been minimized.

Show comment
Hide comment
@kneth

kneth Dec 17, 2015

Contributor

@Kml55 As @cmelchior points out, next release will add Realm.copyFromRealm() which will probably help you. And next release is going very soon ;-)

Contributor

kneth commented Dec 17, 2015

@Kml55 As @cmelchior points out, next release will add Realm.copyFromRealm() which will probably help you. And next release is going very soon ;-)

@apostigl

This comment has been minimized.

Show comment
Hide comment
@apostigl

apostigl Dec 22, 2015

Hi all and thanks for previous replies.

I am trying to use Real.copyFromRealm to pass via Intent Argument a copy of my Realm Object and avoid the NotSerializableException. Problem is that the object I want to pass has two 1-to-N relationships which means it contains a couple of RealmList<>. Instead of having the serializable exception on the ProxyObject I am getting it (predictably) now on the RealmLists it contains (which of course are not serializable).

Any suggestion or best practice to follow? Only way I could imagine is pass the PrimaryKey only and then query for the object as stated before here.

Many thanks!

apostigl commented Dec 22, 2015

Hi all and thanks for previous replies.

I am trying to use Real.copyFromRealm to pass via Intent Argument a copy of my Realm Object and avoid the NotSerializableException. Problem is that the object I want to pass has two 1-to-N relationships which means it contains a couple of RealmList<>. Instead of having the serializable exception on the ProxyObject I am getting it (predictably) now on the RealmLists it contains (which of course are not serializable).

Any suggestion or best practice to follow? Only way I could imagine is pass the PrimaryKey only and then query for the object as stated before here.

Many thanks!

@kneth

This comment has been minimized.

Show comment
Hide comment
@kneth

kneth Dec 22, 2015

Contributor

@apostigl Passing primary keys is probably the best option. In https://github.com/realm/realm-java/tree/master/examples/threadExample/src/main/java/io/realm/examples/threads you might be able to find some inspiration.

Contributor

kneth commented Dec 22, 2015

@apostigl Passing primary keys is probably the best option. In https://github.com/realm/realm-java/tree/master/examples/threadExample/src/main/java/io/realm/examples/threads you might be able to find some inspiration.

@kneth kneth closed this Jan 4, 2016

@kneth kneth removed the Pending label Jan 4, 2016

@akashsenta13

This comment has been minimized.

Show comment
Hide comment
@akashsenta13

akashsenta13 Feb 20, 2016

Hello All,
I am getting same exception while trying to arraylist from one activity to another acitivity in android
I have "public class Data extends RealmObject implements Serializable"

Error Stack :

                                                                            java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = io.realm.DataRealmProxy)
                                                                                at android.os.Parcel.writeSerializable(Parcel.java:1394)
                                                                                at android.os.Parcel.writeValue(Parcel.java:1341)
                                                                                at android.os.Parcel.writeList(Parcel.java:717)
                                                                                at android.os.Parcel.writeValue(Parcel.java:1290)
                                                                                at android.os.Parcel.writeArrayMapInternal(Parcel.java:644)
                                                                                at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313)
                                                                                at android.os.Bundle.writeToParcel(Bundle.java:1034)
                                                                                at android.os.Parcel.writeBundle(Parcel.java:669)
                                                                                at android.content.Intent.writeToParcel(Intent.java:7496)
                                                                                at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2449)
                                                                                at android.app.Instrumentation.execStartActivity(Instrumentation.java:1563)
                                                                                at android.app.Activity.startActivityForResult(Activity.java:3755)
                                                                                at android.app.Activity.startActivityForResult(Activity.java:3716)
                                                                                at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:784)
                                                                                at android.app.Activity.startActivity(Activity.java:4036)
                                                                                at android.app.Activity.startActivity(Activity.java:3998)
                                                                                at com.springinfosoft.quotesapp.SplashActivity$LongOperation.onPostExecute(SplashActivity.java:227)
                                                                                at com.springinfosoft.quotesapp.SplashActivity$LongOperation.onPostExecute(SplashActivity.java:88)
                                                                                at android.os.AsyncTask.finish(AsyncTask.java:636)
                                                                                at android.os.AsyncTask.access$500(AsyncTask.java:177)
                                                                                at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:135)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5343)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
                                                                             Caused by: java.io.NotSerializableException: io.realm.DataRealmProxy$DataColumnInfo
                                                                                at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344)
                                                                                at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                                at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
                                                                                at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
                                                                                at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
                                                                                at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
                                                                                at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                                at android.os.Parcel.writeSerializable(Parcel.java:1389)
                                                                                at android.os.Parcel.writeValue(Parcel.java:1341) 
                                                                                at android.os.Parcel.writeList(Parcel.java:717) 
                                                                                at android.os.Parcel.writeValue(Parcel.java:1290) 
                                                                                at android.os.Parcel.writeArrayMapInternal(Parcel.java:644) 
                                                                                at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313) 
                                                                                at android.os.Bundle.writeToParcel(Bundle.java:1034) 
                                                                                at android.os.Parcel.writeBundle(Parcel.java:669) 
                                                                                at android.content.Intent.writeToParcel(Intent.java:7496) 
                                                                                at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2449) 
                                                                                at android.app.Instrumentation.execStartActivity(Instrumentation.java:1563) 
                                                                                at android.app.Activity.startActivityForResult(Activity.java:3755) 
                                                                                at android.app.Activity.startActivityForResult(Activity.java:3716) 
                                                                                at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:784) 
                                                                                at android.app.Activity.startActivity(Activity.java:4036) 
                                                                                at android.app.Activity.startActivity(Activity.java:3998) 
                                                                                at com.springinfosoft.quotesapp.SplashActivity$LongOperation.onPostExecute(SplashActivity.java:227) 
                                                                                at com.springinfosoft.quotesapp.SplashActivity$LongOperation.onPostExecute(SplashActivity.java:88) 
                                                                                at android.os.AsyncTask.finish(AsyncTask.java:636) 
                                                                                at android.os.AsyncTask.access$500(AsyncTask.java:177) 
                                                                                at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653) 
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                at android.os.Looper.loop(Looper.java:135) 
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5343) 
                                                                                at java.lang.reflect.Method.invoke(Native Method) 
                                                                                at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) 
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) 

akashsenta13 commented Feb 20, 2016

Hello All,
I am getting same exception while trying to arraylist from one activity to another acitivity in android
I have "public class Data extends RealmObject implements Serializable"

Error Stack :

                                                                            java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = io.realm.DataRealmProxy)
                                                                                at android.os.Parcel.writeSerializable(Parcel.java:1394)
                                                                                at android.os.Parcel.writeValue(Parcel.java:1341)
                                                                                at android.os.Parcel.writeList(Parcel.java:717)
                                                                                at android.os.Parcel.writeValue(Parcel.java:1290)
                                                                                at android.os.Parcel.writeArrayMapInternal(Parcel.java:644)
                                                                                at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313)
                                                                                at android.os.Bundle.writeToParcel(Bundle.java:1034)
                                                                                at android.os.Parcel.writeBundle(Parcel.java:669)
                                                                                at android.content.Intent.writeToParcel(Intent.java:7496)
                                                                                at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2449)
                                                                                at android.app.Instrumentation.execStartActivity(Instrumentation.java:1563)
                                                                                at android.app.Activity.startActivityForResult(Activity.java:3755)
                                                                                at android.app.Activity.startActivityForResult(Activity.java:3716)
                                                                                at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:784)
                                                                                at android.app.Activity.startActivity(Activity.java:4036)
                                                                                at android.app.Activity.startActivity(Activity.java:3998)
                                                                                at com.springinfosoft.quotesapp.SplashActivity$LongOperation.onPostExecute(SplashActivity.java:227)
                                                                                at com.springinfosoft.quotesapp.SplashActivity$LongOperation.onPostExecute(SplashActivity.java:88)
                                                                                at android.os.AsyncTask.finish(AsyncTask.java:636)
                                                                                at android.os.AsyncTask.access$500(AsyncTask.java:177)
                                                                                at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:135)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5343)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
                                                                             Caused by: java.io.NotSerializableException: io.realm.DataRealmProxy$DataColumnInfo
                                                                                at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344)
                                                                                at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                                at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
                                                                                at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
                                                                                at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
                                                                                at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
                                                                                at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                                at android.os.Parcel.writeSerializable(Parcel.java:1389)
                                                                                at android.os.Parcel.writeValue(Parcel.java:1341) 
                                                                                at android.os.Parcel.writeList(Parcel.java:717) 
                                                                                at android.os.Parcel.writeValue(Parcel.java:1290) 
                                                                                at android.os.Parcel.writeArrayMapInternal(Parcel.java:644) 
                                                                                at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313) 
                                                                                at android.os.Bundle.writeToParcel(Bundle.java:1034) 
                                                                                at android.os.Parcel.writeBundle(Parcel.java:669) 
                                                                                at android.content.Intent.writeToParcel(Intent.java:7496) 
                                                                                at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2449) 
                                                                                at android.app.Instrumentation.execStartActivity(Instrumentation.java:1563) 
                                                                                at android.app.Activity.startActivityForResult(Activity.java:3755) 
                                                                                at android.app.Activity.startActivityForResult(Activity.java:3716) 
                                                                                at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:784) 
                                                                                at android.app.Activity.startActivity(Activity.java:4036) 
                                                                                at android.app.Activity.startActivity(Activity.java:3998) 
                                                                                at com.springinfosoft.quotesapp.SplashActivity$LongOperation.onPostExecute(SplashActivity.java:227) 
                                                                                at com.springinfosoft.quotesapp.SplashActivity$LongOperation.onPostExecute(SplashActivity.java:88) 
                                                                                at android.os.AsyncTask.finish(AsyncTask.java:636) 
                                                                                at android.os.AsyncTask.access$500(AsyncTask.java:177) 
                                                                                at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653) 
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                at android.os.Looper.loop(Looper.java:135) 
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5343) 
                                                                                at java.lang.reflect.Method.invoke(Native Method) 
                                                                                at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) 
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) 

@RJFares

This comment has been minimized.

Show comment
Hide comment
@RJFares

RJFares Jun 3, 2016

I would like to point out that I'm successfully passing an object implementing RealmModel and Serializable as an argument from one fragment to another (which didn't use to happen before the realmmodel interface)

However I do get the "RuntimeException: Parcelable encountered IOException writing serializable object" / "Caused by: java.io.NotSerializableException"
which happens the moment i press home/recent apps key.
I know how to solve the issue (using a lookup key instead of the object) however, I'm wondering how come it DOES get serialized when i pass it around, yet fails when android tries to saveState...? @cmelchior

RJFares commented Jun 3, 2016

I would like to point out that I'm successfully passing an object implementing RealmModel and Serializable as an argument from one fragment to another (which didn't use to happen before the realmmodel interface)

However I do get the "RuntimeException: Parcelable encountered IOException writing serializable object" / "Caused by: java.io.NotSerializableException"
which happens the moment i press home/recent apps key.
I know how to solve the issue (using a lookup key instead of the object) however, I'm wondering how come it DOES get serialized when i pass it around, yet fails when android tries to saveState...? @cmelchior

@carl1990

This comment has been minimized.

Show comment
Hide comment
@carl1990

carl1990 Nov 7, 2016

I face to same problem .

my mode code is:
public class User extends RealmObject implements Serializable

then pass the object from a fragment to activity as

Intent intent = new Intent();
    intent.putExtra(UserDetailActivity.KEY_USER, user);
    intent.setClass(getContext(), UserDetailActivity.class);
    startActivity(intent);

then app crash and get error info is

FATAL EXCEPTION: main Process: com.zhongan.zachat, PID: 5797
java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = io.realm.UserRealmProxy)
                                                                  at android.os.Parcel.writeSerializable(Parcel.java:1447)
                                                                  at android.os.Parcel.writeValue(Parcel.java:1395)
                                                                  at android.os.Parcel.writeArrayMapInternal(Parcel.java:665)
                                                                  at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)
                                                                  at android.os.Bundle.writeToParcel(Bundle.java:1079)
                                                                  at android.os.Parcel.writeBundle(Parcel.java:690)
                                                                  at android.content.Intent.writeToParcel(Intent.java:7797)
                                                                  at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2641)
                                                                  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1509)
                                                                  at android.app.Activity.startActivityForResult(Activity.java:3973)
                                                                  at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
                                                                  at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
                                                                  at android.support.v4.app.ActivityCompatJB.startActivityForResult(ActivityCompatJB.java:31)
                                                                  at android.support.v4.app.ActivityCompat.startActivityForResult(ActivityCompat.java:169)
                                                                  at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:929)
                                                                  at android.support.v4.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:1043)
                                                                  at android.support.v4.app.Fragment.startActivity(Fragment.java:932)
                                                                  at android.support.v4.app.Fragment.startActivity(Fragment.java:921)
                                                                  at com.zhongan.zachat.ui.activity.contact.ContactsFragment.jumpToUserDetail(ContactsFragment.java:177)
                                                                  at com.zhongan.zachat.ui.activity.contact.ContactsFragment.access$1100(ContactsFragment.java:48)
                                                                  at com.zhongan.zachat.ui.activity.contact.ContactsFragment$StandardArrayAdapter$2.onClick(ContactsFragment.java:239)
                                                                  at android.view.View.performClick(View.java:5200)
                                                                  at android.view.View$PerformClick.run(View.java:21163)
                                                                  at android.os.Handler.handleCallback(Handler.java:739)
                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                  at android.os.Looper.loop(Looper.java:148)
                                                                  at android.app.ActivityThread.main(ActivityThread.java:5456)
                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:735)
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
                                                               Caused by: java.io.NotSerializableException: io.realm.UserRealmProxy$UserColumnInfo
                                                                  at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344)
                                                                  at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                  at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
                                                                  at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
                                                                  at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
                                                                  at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
                                                                  at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                  at android.os.Parcel.writeSerializable(Parcel.java:1442)
                                                                  at android.os.Parcel.writeValue(Parcel.java:1395) 
                                                                  at android.os.Parcel.writeArrayMapInternal(Parcel.java:665) 
                                                                  at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330) 
                                                                  at android.os.Bundle.writeToParcel(Bundle.java:1079) 
                                                                  at android.os.Parcel.writeBundle(Parcel.java:690) 
                                                                  at android.content.Intent.writeToParcel(Intent.java:7797) 
                                                                  at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2641) 
                                                                  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1509) 
                                                                  at android.app.Activity.startActivityForResult(Activity.java:3973) 
                                                                  at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48) 
                                                                  at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75) 
                                                                  at android.support.v4.app.ActivityCompatJB.startActivityForResult(ActivityCompatJB.java:31) 
                                                                  at android.support.v4.app.ActivityCompat.startActivityForResult(ActivityCompat.java:169) 
                                                                  at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:929) 
                                                                  at android.support.v4.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:1043) 
                                                                  at android.support.v4.app.Fragment.startActivity(Fragment.java:932) 
                                                                  at android.support.v4.app.Fragment.startActivity(Fragment.java:921) 
                                                                  at com.zhongan.zachat.ui.activity.contact.ContactsFragment.jumpToUserDetail(ContactsFragment.java:177) 
                                                                  at com.zhongan.zachat.ui.activity.contact.ContactsFragment.access$1100(ContactsFragment.java:48) 
                                                                  at com.zhongan.zachat.ui.activity.contact.ContactsFragment$StandardArrayAdapter$2.onClick(ContactsFragment.java:239) 
                                                                  at android.view.View.performClick(View.java:5200) 
                                                                  at android.view.View$PerformClick.run(View.java:21163) 
                                                                  at android.os.Handler.handleCallback(Handler.java:739) 
                                                                  at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                  at android.os.Looper.loop(Looper.java:148) 
                                                                  at android.app.ActivityThread.main(ActivityThread.java:5456) 
                                                                  at java.lang.reflect.Method.invoke(Native Method) 
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:735) 
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 

carl1990 commented Nov 7, 2016

I face to same problem .

my mode code is:
public class User extends RealmObject implements Serializable

then pass the object from a fragment to activity as

Intent intent = new Intent();
    intent.putExtra(UserDetailActivity.KEY_USER, user);
    intent.setClass(getContext(), UserDetailActivity.class);
    startActivity(intent);

then app crash and get error info is

FATAL EXCEPTION: main Process: com.zhongan.zachat, PID: 5797
java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = io.realm.UserRealmProxy)
                                                                  at android.os.Parcel.writeSerializable(Parcel.java:1447)
                                                                  at android.os.Parcel.writeValue(Parcel.java:1395)
                                                                  at android.os.Parcel.writeArrayMapInternal(Parcel.java:665)
                                                                  at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)
                                                                  at android.os.Bundle.writeToParcel(Bundle.java:1079)
                                                                  at android.os.Parcel.writeBundle(Parcel.java:690)
                                                                  at android.content.Intent.writeToParcel(Intent.java:7797)
                                                                  at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2641)
                                                                  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1509)
                                                                  at android.app.Activity.startActivityForResult(Activity.java:3973)
                                                                  at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
                                                                  at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
                                                                  at android.support.v4.app.ActivityCompatJB.startActivityForResult(ActivityCompatJB.java:31)
                                                                  at android.support.v4.app.ActivityCompat.startActivityForResult(ActivityCompat.java:169)
                                                                  at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:929)
                                                                  at android.support.v4.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:1043)
                                                                  at android.support.v4.app.Fragment.startActivity(Fragment.java:932)
                                                                  at android.support.v4.app.Fragment.startActivity(Fragment.java:921)
                                                                  at com.zhongan.zachat.ui.activity.contact.ContactsFragment.jumpToUserDetail(ContactsFragment.java:177)
                                                                  at com.zhongan.zachat.ui.activity.contact.ContactsFragment.access$1100(ContactsFragment.java:48)
                                                                  at com.zhongan.zachat.ui.activity.contact.ContactsFragment$StandardArrayAdapter$2.onClick(ContactsFragment.java:239)
                                                                  at android.view.View.performClick(View.java:5200)
                                                                  at android.view.View$PerformClick.run(View.java:21163)
                                                                  at android.os.Handler.handleCallback(Handler.java:739)
                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                  at android.os.Looper.loop(Looper.java:148)
                                                                  at android.app.ActivityThread.main(ActivityThread.java:5456)
                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:735)
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
                                                               Caused by: java.io.NotSerializableException: io.realm.UserRealmProxy$UserColumnInfo
                                                                  at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344)
                                                                  at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                  at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
                                                                  at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
                                                                  at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
                                                                  at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
                                                                  at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                                  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                                  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                                  at android.os.Parcel.writeSerializable(Parcel.java:1442)
                                                                  at android.os.Parcel.writeValue(Parcel.java:1395) 
                                                                  at android.os.Parcel.writeArrayMapInternal(Parcel.java:665) 
                                                                  at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330) 
                                                                  at android.os.Bundle.writeToParcel(Bundle.java:1079) 
                                                                  at android.os.Parcel.writeBundle(Parcel.java:690) 
                                                                  at android.content.Intent.writeToParcel(Intent.java:7797) 
                                                                  at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2641) 
                                                                  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1509) 
                                                                  at android.app.Activity.startActivityForResult(Activity.java:3973) 
                                                                  at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48) 
                                                                  at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75) 
                                                                  at android.support.v4.app.ActivityCompatJB.startActivityForResult(ActivityCompatJB.java:31) 
                                                                  at android.support.v4.app.ActivityCompat.startActivityForResult(ActivityCompat.java:169) 
                                                                  at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:929) 
                                                                  at android.support.v4.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:1043) 
                                                                  at android.support.v4.app.Fragment.startActivity(Fragment.java:932) 
                                                                  at android.support.v4.app.Fragment.startActivity(Fragment.java:921) 
                                                                  at com.zhongan.zachat.ui.activity.contact.ContactsFragment.jumpToUserDetail(ContactsFragment.java:177) 
                                                                  at com.zhongan.zachat.ui.activity.contact.ContactsFragment.access$1100(ContactsFragment.java:48) 
                                                                  at com.zhongan.zachat.ui.activity.contact.ContactsFragment$StandardArrayAdapter$2.onClick(ContactsFragment.java:239) 
                                                                  at android.view.View.performClick(View.java:5200) 
                                                                  at android.view.View$PerformClick.run(View.java:21163) 
                                                                  at android.os.Handler.handleCallback(Handler.java:739) 
                                                                  at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                  at android.os.Looper.loop(Looper.java:148) 
                                                                  at android.app.ActivityThread.main(ActivityThread.java:5456) 
                                                                  at java.lang.reflect.Method.invoke(Native Method) 
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:735) 
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 
@Zhuinden

This comment has been minimized.

Show comment
Hide comment
@Zhuinden

Zhuinden Nov 7, 2016

Contributor

@carl1990 you're supposed to either parcel only unmanaged objects created with realm.copyFromRealm(), or you can also choose to just do it right and only send object primary key through and requery in the other Activity in order to retain the consistency that Realm was designed to provide with its zero-copy architecture.

Contributor

Zhuinden commented Nov 7, 2016

@carl1990 you're supposed to either parcel only unmanaged objects created with realm.copyFromRealm(), or you can also choose to just do it right and only send object primary key through and requery in the other Activity in order to retain the consistency that Realm was designed to provide with its zero-copy architecture.

@CCorrado

This comment has been minimized.

Show comment
Hide comment
@CCorrado

CCorrado Mar 30, 2017

Ran into this -- looks like the copyFromRealm() method didn't make it to 3.0.0 (which is fine)

Definitely agreed that you should pass native Android constructs through serializable, and when necessary, set non-native objects as transient. I ended up passing in a String via an intent to a Service (didn't even need the whole object in the first place)

CCorrado commented Mar 30, 2017

Ran into this -- looks like the copyFromRealm() method didn't make it to 3.0.0 (which is fine)

Definitely agreed that you should pass native Android constructs through serializable, and when necessary, set non-native objects as transient. I ended up passing in a String via an intent to a Service (didn't even need the whole object in the first place)

@Zhuinden

This comment has been minimized.

Show comment
Hide comment
@Zhuinden

Zhuinden Mar 30, 2017

Contributor

realm.copyFromRealm() was added in 0.86.0 I think and been there ever since. But sending string is easier.

Contributor

Zhuinden commented Mar 30, 2017

realm.copyFromRealm() was added in 0.86.0 I think and been there ever since. But sending string is easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment