-
Notifications
You must be signed in to change notification settings - Fork 54
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
NotSerializableException
when serializing PurchasesException
#2006
Comments
👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out! |
tonidero
added a commit
that referenced
this issue
Jan 8, 2025
### Description This was requested in #2006
5 tasks
This issue has been automatically locked due to no recent activity after it was closed. Please open a new issue for related reports. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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: