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 to reduce APK package size?
What is Android Fragments?
How to start a new activity on button click
What is "shared preferences" in Android ?
Explain Fragment Life Cycle
How to copy database from assets folder in android using kotlin
How do i load image from drawable folder in Jetpack Compose?
What are symmetric and asymmetric encryption in the way Android interacts with the server?
What is Application?
What happens next when the device switches between portrait and landscape?
How to extract date and time from Long type variable in Kotlin on Android "
What is the Different Between val and var in Kotlin?
Key Points to remember while develop the Android Application.
What is Android?
How to get screen size (width,height) in Android?
How to validate email address in Android with Kotlin?
Android FCM not receiving notifications when app is removed from background
What are Android Versions available?
How to Exit android app on back pressed?
Could not inflate Behavior subclass android.support.design.widget. BottomSheetBehavior How resolve
How to install/ uninstall apk by command line ADB
How to add jar/library files as a dependency in Android studio gradle file
Permission denied for window type 2010 in Marshmallow device
Android Activity FullScreen - How to set activity to fullscreen mode in Android?
Is There A Way To Get The Source Code From An APK File? (or) How to decompile apk?
How to save activity State in Android?
Google play store rejected my app due to SMS permission I removed SMS permission from the manifes
ERR_ACCESS_DENIED in Android Webview with sdk 30
Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path
How do I check in SQLite whether a table exists?
'constructor Handler()' is deprecated. Deprecated in Java, How to use Handler() class in And
Check List for Generate Signed APK Android
ERROR Android emulator gets killed when I try to run my application and choose an emulator it ret
Hide/Disable soft keyboard on Activity launch: Android
How to get a contact image using a phone number in android?
How to check Android version?
How to convert milli seconds to hours, minutes and seconds in Android?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
Duplicate files during packaging of APK” build.gradle issue: Android Studio
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr