Davide Giuseppe Farella
09/12/2020, 3:43 PM// App
workerError.toWorkData()
workData.deserialize(WorkerError.serializer())
// Lib 1
T.toWorkData(SerializationStrategy) = ... this.serialize(strategy)
Data.deserialize(DeserializationStrategy) = ...deserialize(strategy)
// Lib 2
@PublishedApi
internal val Serializer get() = Config.defaultJsonStringFormat
inline fun <reified T : Any> T.serialize(
serializer: SerializationStrategy<T>? = null
) = serializer?.let { Serializer.stringify(serializer, this) } ?: Serializer.stringify(this)
inline fun <reified T : Any> String.deserialize(
deserializer: DeserializationStrategy<T>? = null
): T = deserializer?.let { Serializer.parse(deserializer, this) } ?: Serializer.parse(this)
From the app (JUnit test), when I call workerError.toWorkData()
it does work fine, when I call workData.deserialize(...)
I got
java.lang.NoSuchMethodError: 'kotlinx.serialization.json.Json ....SerializationUtilsKt.getSerializer()
Now: Lib 1 is published with Lib 2 v0.1, which has defaultJsonStringFormat
as Json
App uses Lib 2 v0.2 which has defaultJsonStringFormat
as StringFormat
I still don’t a clear idea about dependencies between libs, but why the first method is working correctly, while the second doesn’t?