https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
k

Kurt Renzo Acosta

06/27/2020, 9:33 AM
Does anyone know how to solve this? I'm trying to use Firestore's IgnoreExtraProperties on KMP.
Copy code
// Common
expect annotation class IgnoreExtraProperties()

// Android
actual typealias IgnoreExtraProperties = com.google.firebase.firestore.IgnoreExtraProperties
However, when I try to run it, I get a
This class does not have a constructor
. I also did this but no luck. Maybe it's because the actual annotation is just an interface?
Copy code
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface IgnoreExtraProperties {
}
Anyway, any help would be greatly appreciated!
p

pajatopmr

01/30/2021, 7:54 PM
My educated guess is that you want to start by implementing the interface and then, because the implementing class will be polymorphic when you add the @Serializable annotation, you will need to deal with "registering" the implementation in the scope of the interface. That means using a format + module or one of the ...PolymorphicSerializer strategies. My preferred solution is to use the JsonContentPolymorphicSerializer. Hope that helps.
3 Views