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?
Check List for Generate Signed APK Android
How to start a new activity on button click
Hide/Disable soft keyboard on Activity launch: Android
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How to Use Deprecated Handler() in Android - RRutors Guide
How to get a contact image using a phone number in android?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
How to check Android version?
How to convert DP to Pixel and Pixel to Dp?
Explain Fragment Life Cycle
What is NetworkOnMainThread Exception?
What is Android?
Fix Duplicate Files in APK Build.gradle Issue - RRutors
FCM Not Receiving Notifications in Android - RRutors
Extract Date and Time from Long Type Variable - RRutors
How to get screen size (width,height) in Android?
How to Get bitmap from drawable: Android
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
What are the notifications available in android?
How do I generate random numbers in Dart?
What is ANR in android?
Key Points to remember while develop the Android Application.
How to get complete address from latitude and longitude?
Add Jar/Library Files as Dependency in Android Studio
How To Set Text Color Programmatically Android TextView?
What is "shared preferences" in Android ?
How to stop EditText focus at Activity startup in Android?
What is the difference between match_parent and fill_parent?
How to get an image resource by it's name in android?
How to Exit android app on back pressed?
Set Activity to Fullscreen Mode in Android - RRutors
What is the Different Between val and var in Kotlin?
Fix Android Emulator Kill Error When Running Your App
How to validate email address in Android with Kotlin?
How do I check in SQLite whether a table exists?
What is Context?
How to reduce APK package size?
How do i load image from drawable folder in Jetpack Compose?
Fix Play Store Rejection Due to SMS Permission - RRutors