How do I use polymorphic serializers with split so...
# serialization
m
How do I use polymorphic serializers with split sourcesets? I get
Copy code
kotlinx.serialization.SerializationException: Serializer for subclass 'MaterialAppTheme' is not found in the polymorphic scope of 'AppTheme'.
Check if class with serial name 'MaterialAppTheme' exists and serializer is registered in a corresponding SerializersModule.
To be registered automatically, class 'MaterialAppTheme' has to be '@Serializable', and the base class 'AppTheme' has to be sealed and '@Serializable'.
where MaterialAppTheme is an
expect class
, with the
@Serializable
on the
actual class
declarations. I can't put the annotation on the
expect class
because it doesn't have any properties in its primary constructor.
r
Why do you want to serialize the app theme?
If you only need the information of
MaterialAppTheme
then you can create another serializable class that has the same parameters but not extends anything and write a function to convert those.
m
Different AppTheme classes have different behaviors to render elements differently.