question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to invoke no-args constructor for retrofit2.Call

See original GitHub issue

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) 

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
zy888802commented, Oct 10, 2019

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

3reactions
JakeWhartoncommented, Oct 10, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to invoke no-args constructor for retrofit2.Call
The problem is that you try to combine suspend with a Call<T> return type. When you use suspend you should make the Retrofit...
Read more >
Gson 1.7: Unable to invoke no-args constructor for class org ...
Hello all, I though no-args constructors were no longer required in 1.7. Is there something about DateTimeZone that keeps this from working?
Read more >
Retrofit 2.0 + GSON Unable to invoke no-args constructor for ...
Unable to invoke no -args constructor for interface com.example.project.API.GetPhones. Register an InstanceCreator with Gson for this type may fix this problem.
Read more >
Hi. I have followed your article for implementing this code and ...
ava.lang.RuntimeException: Unable to invoke no-args constructor for retrofit2.Call<com.yourPackageName.model.SignUpResponse>.
Read more >
Serialization of Java objects using Google's Gson library
Gson requires the class to have a default no-args constructor. If the no-args constructor is not provided, we can register an InstanceCreator with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found