Type mismatch. Required: List<DogResponse> Found: List<String> in kotlin retrofit

  android, gson, kotlin, retrofit2, type-mismatch

I am developing a new android where I am getting images by using retrofit in android but I am getting the following errors below
TypeMismatch error

following my json structure
json structure

below my DogResponse data class

data class DogResponse(
    val message: List<String>,
    val status: String

below my network logic

interface DogInterface {
  fun getDogImage(): Call<DogResponse>

below retrofit logic

object ServiceBuilder {
    private val client = OkHttpClient.Builder().build()

    private val retrofit = Retrofit.Builder()

    fun<T> buildService(service: Class<T>): T{
        return retrofit.create(service)

below my Adapter class

class DogAdapter(private val data: List<DogResponse>) : RecyclerView.Adapter<DogAdapter.MyViewHolder>()  {

    class MyViewHolder(val view: View): RecyclerView.ViewHolder(view){

        fun bind(dogResponse: DogResponse){

            val imageView = view.findViewById<ImageView>(R.id.imageView)


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
        val v = LayoutInflater.from(parent.context).inflate(R.layout.list_item, parent, false)
        return MyViewHolder(v)

    override fun getItemCount(): Int {
        return data.size

    override fun onBindViewHolder(holder: MyViewHolder, position: Int) {


below my retrofit call in MainActivity.kt

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {

    val request = ServiceBuilder.buildService(DogInterface::class.java)
    val call = request.getDogImage()
    call.enqueue(object : Callback<DogResponse> {
        override fun onResponse(call: Call<DogResponse>, response: Response<DogResponse>) {
            if (response.isSuccessful) {
                progress_bar.visibility = View.GONE
                recycler_view.apply {
                    layoutManager = LinearLayoutManager([email protected])
                    adapter = DogAdapter(response.body().message)

        override fun onFailure(call: Call<DogResponse>, t: Throwable) {
            Toast.makeText([email protected], "${t.message}", Toast.LENGTH_SHORT).show()


I want to know where I am making a mistake

Source: Android Questions

One Reply to “Type mismatch. Required: List<DogResponse> Found: List<String> in kotlin retrofit”