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();
Permission denied for window type 2010 in Marshmallow device
How to find Android Device UDID or unique ID?
Android Studio project R can't find
How to reduce APK package size?
How to get screen size (width,height) in Android?
How do I check in SQLite whether a table exists?
How to start a new activity on button click
Fix Duplicate Files in APK Build.gradle Issue - RRutors
How To Set Text Color Programmatically Android TextView?
How to validate email address in Android with Kotlin?
What happens next when the device switches between portrait and landscape?
How to get a contact image using a phone number in android?
What is ANR? How to avoid and resolve it?
How to get complete address from latitude and longitude?
Explain Fragment Life Cycle
Set Activity to Fullscreen Mode in Android - RRutors
What is Intent? What is the difference between an implicit intent and an explicit intent?
How to Get bitmap from drawable: Android
What is Context?
What is the difference between match_parent and fill_parent?
FCM Not Receiving Notifications in Android - RRutors
Fix Play Store Rejection Due to SMS Permission - RRutors
Symmetric vs Asymmetric Encryption in Android Server - RRutors
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
How to Generate signed apk with android studio
Open PDF in Google Drive with Intent in Android - RRutors
How do i load image from drawable folder in Jetpack Compose?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
ERR_ACCESS_DENIED in Android Webview with sdk 30
Check List for Generate Signed APK Android
How to save activity State in Android?
How to convert milli seconds to hours, minutes and seconds in Android?
What are the notifications available in android?
Extract Date and Time from Long Type Variable - RRutors
Add Jar/Library Files as Dependency in Android Studio
How to avoid multiple button click at same time in android?
What is the Different Between val and var in Kotlin?
What is ANR in android?