You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PurchasesException inherits from Exception which inherits from Throwable which implements Serializable, so it must be “serializable” but it’s not.
When you try to serialize a PurchasesException, a NotSerializableException is thrown because the underlying PurchasesError doesn’t implement Serializable.
In the case of my app (which keeps some Exceptions for error dialog), it crashes when onSaveInstanceState is called.
Environment
Platform: Android
SDK version: 8.10.6
OS version: 15
Android Studio version:
How widespread is the issue. Percentage of devices affected.
android.os.BadParcelableException: Parcelable encountered IOException writing serializable object (name = com.revenuecat.purchases.PurchasesException)
at android.os.Parcel.writeSerializable(Parcel.java:2966)
at android.os.Parcel.writeValue(Parcel.java:2732)
at android.os.Parcel.writeValue(Parcel.java:2531)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:1395)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1843)
at android.os.Bundle.writeToParcel(Bundle.java:1483)
at android.os.Parcel.writeParcelable(Parcel.java:2753)
...
Caused by: java.io.NotSerializableException: com.revenuecat.purchases.PurchasesError
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1240)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1620)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1581)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1490)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1234)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:354)
at android.os.Parcel.writeSerializable(Parcel.java:2961)
...
Describe the bug
PurchasesException
inherits fromException
which inherits fromThrowable
which implementsSerializable
, so it must be “serializable” but it’s not.When you try to serialize a
PurchasesException
, aNotSerializableException
is thrown because the underlyingPurchasesError
doesn’t implementSerializable
.In the case of my app (which keeps some
Exception
s for error dialog), it crashes whenonSaveInstanceState
is called.Environment
Debug logs that reproduce the issue
Steps to reproduce, with a description of expected vs. actual behavior
PurchasesException
.Expected:
PurchasesException
is serialized.Actual:
NotSerializableException
is thrown.Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)
Sample code:
Here are some suggestions:
Make
PurchasesError
aSerializable
Simply implement
Serializable
.purchases/src/main/kotlin/com/revenuecat/purchases/errors.kt:
or
Override the
writeObject
/readObject
methods ofPurchasesException
When serializing, convert
PurchasesError
into a byte array withParcel
and write it to the stream. And do the reverse when deserializing.purchases/src/main/kotlin/com/revenuecat/purchases/PurchasesException.kt:
Add the following configuration to Proguard:
https://www.guardsquare.com/manual/configuration/examples#serializable
Additional context
Thanks.
The text was updated successfully, but these errors were encountered: