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();
How do I generate random numbers in Dart?
ERR_ACCESS_DENIED in Android Webview with sdk 30
Android Studio project R can't find
Key Points to remember while develop the Android Application.
How to Generate signed apk with android studio
How to check Android version?
How To Set Text Color Programmatically Android TextView?
Symmetric vs Asymmetric Encryption in Android Server - RRutors
How to Get bitmap from drawable: Android
Decompile APK Files: How to Get Source Code - RRutors Guide
How can i comment inside xml file in android studio?
How to save activity State in Android?
How to start a new activity on button click
How to get screen size (width,height) in Android?
How to get a contact image using a phone number in android?
Fix Android Emulator Kill Error When Running Your App
What is "shared preferences" in Android ?
How to convert milli seconds to hours, minutes and seconds in Android?
What are Android Versions available?
Fix Duplicate Files in APK Build.gradle Issue - RRutors
How to Use Deprecated Handler() in Android - RRutors Guide
Permission denied for window type 2010 in Marshmallow device
Add Jar/Library Files as Dependency in Android Studio
How to get complete address from latitude and longitude?
Invoke-customs are only supported starting with android 0 --min-api 26
How to validate email address in Android with Kotlin?
What is Intent? What is the difference between an implicit intent and an explicit intent?
What is Context?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
What is the Different Between val and var in Kotlin?
What is NetworkOnMainThread Exception?
How do I check in SQLite whether a table exists?
What is Android?
What is the difference between match_parent and fill_parent?
What is ANR? How to avoid and resolve it?
How to stop EditText focus at Activity startup in Android?
What happens next when the device switches between portrait and landscape?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
Hide/Disable soft keyboard on Activity launch: Android
What is Application?