Fatal exception on handling the Flickr Response - Moshi Converter issue

I was getting the following error when I switched to Moshi converter and hoping that it would be able to handle FlickrResponse through fetchPhotos method.

FATAL EXCEPTION: main
Process: com.bignerdranch.android.photogallery, PID: 30598
java.lang.IllegalArgumentException: Unable to create converter for class com.bignerdranch.android.photogallery.api.FlickrResponse
for method FlickrApi.fetchPhotos

Looks Seems like you need to create a Kotlin adapter first and pass it on the MoshiConverterFactory’s create method as a parameter:

init {
    // Kotlin reflection adapter
    val moshi = Moshi.Builder()
        .add(KotlinJsonAdapterFactory())
        .build()

    val retrofit: Retrofit = Retrofit.Builder()
        .baseUrl(BASE_URL)
        .addConverterFactory(MoshiConverterFactory.create(moshi))
        .build()
    flickrApi = retrofit.create(FlickrApi::class.java)
}

Hope it helps others who have ran into this!