-
Notifications
You must be signed in to change notification settings - Fork 2
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
java.lang.ClassCastException: com.revenuecat.purchases.models.GoogleStoreProduct cannot be cast to io.shortway.kobankat.models.StoreProduct #48
Comments
Hi, thanks for flagging this! If you don't add type casting, which target are you building that throws the build error? I'm currently on holiday so I can't try to reproduce it myself unfortunately. |
Target Android has this error. IOS not. I just want to copy products in cacheStoreProductsList: List to purchase it via productId finding from cacheStoreProductList. Because I pass only Id to uiState. I changed my strategy after that crash. I used Package to purchase via identifier. There is no issue with Package |
I'm also seeing Could it be this line that is confusing things? |
@Moozart Good to hear you found a workaround! For some reason StoreProduct is not a type alias, while most other classes are. I'm not sure what the reason for that was anymore. Since I'm currently on holiday, I'll be able to look at this in about 2 weeks or so. |
@JayShortway No stress! You've done plenty already! =) I might take a stab at it if I get time before you're back. Not my area of expertise, though, so no promises. 😅 |
@Qw4z1 Oh yes, that's very welcome of course! Feel free to take a look if you have the time, but no worries if you don't. |
I have a reproducer which should be run on CI once #56 is merged, to prevent regressions. Haven't had time to think about a proper fix yet though. |
The reason for this is that the official SDK defines |
Another way to solve it is to write wrapper classes instead of expect/actuals and expose |
@Qw4z1 That's true! In general it's a good suggestion to look at firebase-kotlin-sdk for inspiration. However that's quite a big refactor. I think for now a more pragmatic solution would be to rename the @Moozart That means the field to get the |
Hello,
When I use map like this in composeApp module
availablePackages.map { pack -> pack.product as StoreProduct}
Throws java.lang.ClassCastException: com.revenuecat.purchases.models.GoogleStoreProduct cannot be cast to io.shortway.kobankat.models.StoreProduct
If don't add type casting, throws build time error
Type mismatch: inferred type is com.revenuecat.purchases.models.StoreProduct but io.shortway.kobankat.models.StoreProduct was expected
Do you have any idea or advice.
Thanks to you for good libray
The text was updated successfully, but these errors were encountered: