moko-resources icon indicating copy to clipboard operation
moko-resources copied to clipboard

Compatiblity issues with K2 compiler

Open sanjeevirajm opened this issue 1 year ago • 6 comments

https://youtrack.jetbrains.com/issue/KT-60437/K2-problem-with-Parcelable-plugin https://youtrack.jetbrains.com/issue/KT-59480/K2-build-moko-resources

Looks like there is no way to use Parcelable in KMM anymore. Probably need to remove all Parcelable related feature to make it work in K2 compiler

sanjeevirajm avatar Sep 01 '23 12:09 sanjeevirajm

or it is better to move to Java serializable class. it will still work in K2 compiler because it doesn't need annotation, code generation, ksp

sanjeevirajm avatar Sep 28 '23 15:09 sanjeevirajm

We can use kotlinx-serialization I guess @sanjeevirajm

moffpage avatar Oct 07 '23 19:10 moffpage

@moffpage Java serialisation and Parcelable has a major advantage -

  1. bundle.putSerializable()/putParcelable() - it will just keep the object reference in memory and will do actual serialization only when activity has went to onStop state
  2. bundle.putString(convertObjectToStringUsingKotlinxSerialization()) - will do serialization even before it is needed

sanjeevirajm avatar Oct 19 '23 11:10 sanjeevirajm

Maybe it's true idk, just a suggestion because there's another developer (Googler), that maintains a set of KMP libraries; he changed the implementation of some of the details in one of his library from Parcelable to Kotlinx.Serialization

moffpage avatar Oct 20 '23 01:10 moffpage

Moko-resources runtime could potentially implement kotlinx.serialization annotations and the end user could use https://github.com/chRyNaN/serialization-parcelable. It uses original Parcel instance for encoding/decoding, so there would not be problem, described by @sanjeevirajm above. Fix me if i'm wrong)

Pschsch avatar Nov 14 '23 13:11 Pschsch

Alternative from Jetbrains - Compose multiplatform beta now supports string resource sharing. https://github.com/JetBrains/compose-multiplatform/releases/tag/v1.6.0-beta01

sanjeevirajm avatar Feb 08 '24 14:02 sanjeevirajm

fixed in 0.24.0-beta-1

Alex009 avatar Apr 19 '24 15:04 Alex009