Open GoogleCodeExporter opened 9 years ago
Hi. Today got this crash. Gson parsed my object like
ArrayList<LinkedTreeMap<Node<String, String>. This object convert to byte[]
like this :
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
objOutStream = new ObjectOutputStream(outStream);
objOutStream.writeObject(obj);
So, I got exception :
java.io.NotSerializableException:
ru.tcsbank.wallet.gson.patched.internal.LinkedTreeMap$1
and could not write serialized object to byte array.
Original comment by d3M1d...@gmail.com
on 2 Feb 2015 at 4:27
And yes. I dont know about true reason, but if I dont have proguard, this code
works perfect.
Original comment by d3M1d...@gmail.com
on 2 Feb 2015 at 4:30
I ran into this same issue and it appears to be a configuration issue with the
default proguard file provided by google (in my case of android). You basically
need to maintain additional methods when it comes to serializable classes. You
can read section "Processing serializable classes" here for more info
http://proguard.sourceforge.net/manual/examples.html#serializable
Long story short, add this to your proguard file so they aren't stripped out.
-keepclassmembers class * implements java.io.Serializable {
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
Original comment by spark...@gmail.com
on 6 May 2015 at 2:21
Haven't tested this but spark's comment seems reasonable. I guess this issue
should be closed as user error.
Original comment by jaroslav...@lemberg.co.uk
on 6 May 2015 at 10:43
This should be added to some of the serializable notes somewhere in the android
guide. By default when building using AndroidStudio, the bug did not show up in
the debug build but it shows in the release build.
Original comment by cha...@gmail.com
on 2 Jun 2015 at 3:40
Original issue reported on code.google.com by
jaroslav...@lemberg.co.uk
on 23 Jan 2015 at 1:45