``` java.lang.IllegalArgumentException: Unable ...
# squarelibraries
k
Copy code
java.lang.IllegalArgumentException: Unable to create converter for com.kevincianfarini.saddle.data.network.PaginatedResponse<com.kevincianfarini.saddle.Artist>
        for method SaddleAPI.getArtists
        at retrofit2.Utils.methodError(Utils.java:52)
        at retrofit2.HttpServiceMethod.createResponseConverter(HttpServiceMethod.java:115)
        at retrofit2.HttpServiceMethod.parseAnnotations(HttpServiceMethod.java:82)
        at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:37)
        at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
        at retrofit2.Retrofit$1.invoke(Retrofit.java:149)
        at java.lang.reflect.Proxy.invoke(Proxy.java:913)
        at $Proxy0.getArtists(Unknown Source)
        at com.kevincianfarini.saddle.data.network.saddle.SaddleAPIManager.getArtists(SaddleAPIManager.kt:11)
        at com.kevincianfarini.saddle.data.repository.ArtistRepository$syncChannel$2.invokeSuspend(ArtistRepository.kt:28)
        at com.kevincianfarini.saddle.data.repository.ArtistRepository$syncChannel$2.invoke(Unknown Source:33)
        at com.kevincianfarini.saddle.data.repository.Repository$exhaustPagination$2$1.invokeSuspend(Repository.kt:41)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
com.kevincianfarini.saddle.Artist
is a model object generated by SQLDelight. I tried using
Artist.Impl
which didn't help. Not quite sure what the problem it's complaining about is.
PaginatedResponse
looks like this
Copy code
data class PaginatedResponse<out T>(
    val next: Int?,
    val count: Int,
    val data: List<T>
)
d
Have you marked the classes as
@Serializable
?
k
@Dominaezzz how might I go about marking them as
@Serializable
since some of the classes are generated from SQLDelight
j
You would have to register a serializer separately somehow. I don't remember off hand (and on mobile) how to do it
k
looks like we want something like this
Copy code
@Serializer(forClass=Data::class)
object ExtDataSerializer
d
Ah yes, that might work on JVM.
k
the docs i've read mention that it only doesn't work on js.
So, I'm still running into the same error. Looking further down the stacktrace than what I provided earlier yields this.
Copy code
Caused by: kotlinx.serialization.SerializationException: Can't locate argument-less serializer for class com.kevincianfarini.saddle.Artist$Impl (Kotlin reflection is not available). For generic classes, such as lists, please provide serializer explicitly.
for reference,
Artist$Impl
is a class generated by SQLDelight and has a serializer associated with it via the method above. The class looks like this.
Copy code
interface Artist {
    val id: Long

    val name: String?

    val image: String?

    data class Impl(
        override val id: Long,
        override val name: String?,
        override val image: String?
    ) : Artist {
        override fun toString(): String = """
        |Artist.Impl [
        |  id: $id
        |  name: $name
        |  image: $image
        |]
        """.trimMargin()
    }
}
I've made sure that kotlinx serialization is included in my classpath and that the plugin is being used. I still get the same error. Do any of you have any insight on this?
d
What about
Artist
?
k
what about it?
d
Is it yours or SQLDelight's?
k
it's SQLDelight's
SQLDelight (right now) generates an interface which provides an impl as a data class
d
What about
PaginatedResponse
?
k
I've tried deserializing to both without luck
d
You might be able to mark that class instead.
k
Copy code
@Serializable
data class PaginatedResponse<out T>(
    val next: Int?,
    val count: Int,
    val data: List<T>
)
d
Oh rip, it's generic.
k
can kotlinx serialization not handle that?
d
It can but I'm not sure if the retrofit adaptor can.
k
aaaah
@jw
guess we'll find out 🙂
thanks for the help