First Check your server response is valid JSON or Not if not make it proper To check the resposne you can add loggingInterceptor for OkHttpClient OkHttpClient client = new OkHttpClient.Builder() long t1 = System.nanoTime(); Response response = chain.proceed(request); long t2 = System.nanoTime(); Log.v("Request ","Response: " + responseString); return response.newBuilder() If every thing fine add GsonConverter with below code GsonBuilder gsonBuilder=new GsonBuilder(); Finally Retrofit object creation should be like below
.addInterceptor(new LoggingInterceptor()).build();
static class LoggingInterceptor implements Interceptor {
@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
Request request = chain.request();
Log.v("Request ",String.format("Sending request %s on %s%n%s",
request.url(), chain.connection(), request.headers()));
Log.v("Request ",String.format("Received response for %s in %.1fms%n%s",
response.request().url(), (t2 - t1) / 1e6d, response.headers()));
final String responseString = new String(response.body().bytes());
.body(ResponseBody.create(response.body().contentType(), responseString))
.build();
}}
gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
gsonBuilder.setLenient();
Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create(gsonBuilder.create()))
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.baseUrl(ApiCall.BASE_IRL)
.client(client)
.build();
What is "shared preferences" in Android ?
What is Android?
How to Use Deprecated Handler() in Android - RRutors Guide
How to get complete address from latitude and longitude?
Decompile APK Files: How to Get Source Code - RRutors Guide
How to convert DP to Pixel and Pixel to Dp?
How to get a contact image using a phone number in android?
How to find Android Device UDID or unique ID?
What are Android Versions available?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How can i comment inside xml file in android studio?
What is Android Fragments?
How to avoid multiple button click at same time in android?
How To Set Text Color Programmatically Android TextView?
How to Generate signed apk with android studio
Hide/Disable soft keyboard on Activity launch: Android
Explain Fragment Life Cycle
ERR_ACCESS_DENIED in Android Webview with sdk 30
How to Get bitmap from drawable: Android
What is the Different Between val and var in Kotlin?
Open PDF in Google Drive with Intent in Android - RRutors
FCM Not Receiving Notifications in Android - RRutors
How to start a new activity on button click
Android Studio project R can't find
How to copy database from assets folder in android using kotlin
What is Context?
How to reduce APK package size?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
What is ANR? How to avoid and resolve it?
What happens next when the device switches between portrait and landscape?
What is NetworkOnMainThread Exception?
Invoke-customs are only supported starting with android 0 --min-api 26
How to check Android version?
Fix Play Store Rejection Due to SMS Permission - RRutors
What is the difference between match_parent and fill_parent?
Add Jar/Library Files as Dependency in Android Studio
How do I generate random numbers in Dart?
What are the notifications available in android?
How to convert milli seconds to hours, minutes and seconds in Android?
What is Intent? What is the difference between an implicit intent and an explicit intent?