Understanding Android OS!

Photo by Stephen Frank on Unsplash

Let’s take a different approach to understand android OS internals.

Have you come across these questions?
1.Why system apps can not be uninstalled?
2.How sandboxing for the android app is handled by the system?
3.When the crash is logged in the console we see a Zygote for every crash and…


I was integrating Api ( Webservice) in android app I came across following error.

com.google.gson.stream.MalformedJsonException: JSON forbids NaN and infinities: NaN at line 1 column 123 path

I was using Retrofit with GsonConverter. Section 2.4 of JSON specification disallows special double values (NaN, Infinity, -Infinity).

so how to solve this problem?

we can use Following GsonBuilder properties

serializeSpecialFloatingPointValues()
or
serializeNulls()
or
setLenient()

your final Retrofit client should look like this

public static Retrofit getClient() {

Gson gson =
new GsonBuilder()
.serializeNulls()
.serializeSpecialFloatingPointValues()
.setLenient()
.create();


String baseurl = BuildConfig.BASE_URL;


retrofit = new Retrofit.Builder()
.baseUrl(baseurl)
.client(getHttpClient())
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();

return retrofit;
}

Hope it helps.

akshay shahane

Researcher by fate developer by choice

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store