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 happens next when the device switches between portrait and landscape?
Symmetric vs Asymmetric Encryption in Android Server - RRutors
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
What is Intent? What is the difference between an implicit intent and an explicit intent?
Invoke-customs are only supported starting with android 0 --min-api 26
How to reduce APK package size?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How to validate email address in Android with Kotlin?
How to check Android version?
Open PDF in Google Drive with Intent in Android - RRutors
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
Add Jar/Library Files as Dependency in Android Studio
How to copy database from assets folder in android using kotlin
How to Generate signed apk with android studio
FCM Not Receiving Notifications in Android - RRutors
Key Points to remember while develop the Android Application.
How to convert milli seconds to hours, minutes and seconds in Android?
How can i comment inside xml file in android studio?
ERR_ACCESS_DENIED in Android Webview with sdk 30
What is ANR? How to avoid and resolve it?
How to get a contact image using a phone number in android?
How to Use Deprecated Handler() in Android - RRutors Guide
How to Get bitmap from drawable: Android
What is NetworkOnMainThread Exception?
Check List for Generate Signed APK Android
How to convert DP to Pixel and Pixel to Dp?
How to Exit android app on back pressed?
Android Studio project R can't find
How to avoid multiple button click at same time in android?
How to save activity State in Android?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
Fix Android Emulator Kill Error When Running Your App
How do i load image from drawable folder in Jetpack Compose?
Explain Fragment Life Cycle
Extract Date and Time from Long Type Variable - RRutors
What is "shared preferences" in Android ?
How do I check in SQLite whether a table exists?
What is Android Fragments?
What are the notifications available in android?
What is Context?