Hi all! I’m having an annoying problem with Progua...
# serialization
d
Hi all! I’m having an annoying problem with Proguard for Kotlinx Serialization. I have a class like this
Copy code
@Serializable
data class PagedResult<T, P : PagedResult.Pagination>(val items: List<T>, val pagination: P)
Everything works fine until the moment when I enable Proguard. An error like this occurs: java.lang.IllegalArgumentException: Unable to create converter for f.a.b.d.i.g.a<> (). f.a.b.d.i.g.a is just a class PagedResult (I see it in mapping.txt) The rules for Proguard are taken from the official kotlinx.serialization repository. Can someone tell me what the problem is?
e
are you using reflection?
note that
Json.encodeToString<T>()
Json.decodeFromString<T>()
look up the serializer reflectively, which means Proguard doesn't see a hard reference to it
if that's the case, try using
Copy code
val serializer = PagedResult.serializer(ItemType.serializer(), PaginationType.serializer())
Json.encodeToString(serializer, data)
Json.decodeFromString(serializer, data)