Android + Retrofit 2 + Gson = Unable To Invoke No-args Constructor For Interface
I'm trying to use retrofit 2 in my app and i'm getting the folloing error: java.lang.RuntimeException: Unable to invoke no-args constructor for interface box.gov.br.ourapp.API.Clie
Solution 1:
I think there is a problem because you user same name for interface
class and your Model
class.
both are same name here ClientePFApi
.
publicinterfaceClientePFApi {
@GET("clientepf/{user}")
Call<ClientePFApi> getClientePF(@Path("user") String user);
}
you use ClientePFVisao360
like below
publicinterfaceClientePFApi {
@GET("clientepf/{user}")
Call<ClientePFVisao360> getClientePF(@Path("user") String user);
}
Solution 2:
You must to Change <Call>
to <Response>
Solution 3:
if for example your api service method is this
interfaceExampleInterface{
@POST("sample")suspendfunsampleFun(): Call<JsonObject>
}
change it to this
interfaceExampleInterface{
@POST("sample")funsampleFun(): Call<JsonObject>
}
Post a Comment for "Android + Retrofit 2 + Gson = Unable To Invoke No-args Constructor For Interface"