Retrofit: Unable to invoke no-args constructor for retrofit2.Call

Created on 10 Oct 2019  ·  4Comments  ·  Source: square/retrofit

Version : retrofit 2.6.2
Json: GsonConverterFactory

When I use Call.awaitResponse() Call.await() hava error
but I use Call.enqueue() Call.execute() no problem

java.lang.RuntimeException: Unable to invoke no-args constructor for retrofit2.Call. Registering an InstanceCreator with Gson for this type may fix this problem.
        at com.google.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:228)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:212)
        at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:39)
        at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27)
        at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:225)
        at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:121)
        at okhttp3.RealCall$AsyncCall.run(RealCall.kt:138)
        at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:784)
 Caused by: java.lang.UnsupportedOperationException: Interface can't be instantiated! Interface name: retrofit2.Call
        at com.google.gson.internal.UnsafeAllocator.assertInstantiable(UnsafeAllocator.java:117)
        at com.google.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:49)
        at com.google.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:225)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:212) 
        at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:39) 
        at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27) 
        at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:225) 
        at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:121) 
        at okhttp3.RealCall$AsyncCall.run(RealCall.kt:138) 
        at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:784) 

Needs Info

Most helpful comment

suspend fun(..): Call<..>
I delete suspend to solve the problem
Thank you very much!

All 4 comments

Please provide a complete failing test case or reproducing sample. Seems like you're doing something like Call<Call<..>> or suspend fun(..): Call<..>.

suspend fun(..): Call<..>
I delete suspend to solve the problem
Thank you very much!

suspend fun(..): Call<..>
I delete suspend to solve the problem
Thank you very much!

Thank you

suspend fun(..): Call<..>
I delete suspend to solve the problem
Thank you very much!

Thank you sooooooo much

Was this page helpful?
0 / 5 - 0 ratings