Below are the Dependencies which I have used
implementation 'com.squareup.retrofit2:retrofit:2.0.2'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
Below is the code which I am calling retrofit API
RequestBody jsonBody = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"),(jsonInput));
RetrofitAPI cashMemoService = RetrofitAPICLient.getClient().create(RetrofitAPI.class);
Call<List<CashMemoDetails>> call = cashMemoService.getCashMemoPendingListObj(jsonBody);
This is RetrofitAPICLient
public static Retrofit getClient(){
if(retrofit == null){
retrofit = new Retrofit.Builder()
.baseUrl(newBseURL)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
Below is the Interface
@POST("GetCashMemoPunchingList")
Call<List<CashMemoDetails>> getCashMemoPendingListObj(@Body RequestBody userData);
Below is the exception which I am getting
2020-10-20 10:59:47.320 27155-27155/ W/com.hpcl.gsa2: Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (greylist,core-platform-api, reflection, allowed)
2020-10-20 10:59:47.335 27155-27155/ W/System.err: java.lang.IllegalArgumentException: Unable to create call adapter for interface g.g
55-27155/ W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
2020-10-20 10:59:47.336 27155-27155/ W/System.err: Caused by: java.lang.IllegalArgumentException: Call return type must be parameterized as Call<Foo> or Call<? extends Foo>
2020-10-20 10:59:47.336 27155-27155/ W/System.err: ... 22 more
Please help me on this.Thanks in advance
This question is quite old but the problem seems to reappear from time to time. I had this error as well using Gradle 8.2.1 and com.android.tools.build:gradle 8.0.2 and a downgrade to com.android.tools.build:gradle 7.4.2 fixed it! But a downgrade is not really a solution, so I investigated a bit further
I was able to fix it by adding some of the Proguard rules from here (nameley Retrofit and Okhttp rules)
-keep class retrofit2.** { *; }
-keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
You should also make sure that your retrofit and Okhttp versions are up-to-date and that you follow the proguard / R8 config hints laid out in the Readme
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With