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
Richard
07/08/2024, 5:01 AM
Why do you want to serialize the app theme?
Richard
07/08/2024, 5:05 AM
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
martmists
07/08/2024, 10:04 AM
Different AppTheme classes have different behaviors to render elements differently.