[Android] NullPointerException in extractErrorString due to null Throwable in setAuthTokens API call | Community
Skip to main content

A NullPointerException is occurring in the Intercom Android SDK, specifically within the extractErrorString function. The crash happens when the SDK attempts to call getMessage() on a null Throwable object.

Stack Trace:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Throwable.getMessage()' on a null object reference
at io.intercom.android.sdk.api.ErrorStringExtractorKt.extractErrorString(ErrorStringExtractor.kt:16)
...

Root Cause Analysis:

Upon decompiling the SDK's code, we've identified the root cause in the onResponse method of the setAuthTokens API call.

In the onResponse method, when an API response is not successful (!response.isSuccessful()), an ErrorObject is created with a Throwable that is explicitly passed as null.

ErrorObject errorObject = new ErrorObject((Throwable)null, response);

This ErrorObject is then passed to extractErrorString, which, within its catch block (specifically when parsing the error JSON fails), attempts to get the message from the null Throwable, leading to the NullPointerException.

 

Be the first to reply!