A
A
AndroidM2018-09-17 12:27:56
Java
AndroidM, 2018-09-17 12:27:56

How to fix NullPointerException in okhttp response?

I immediately apologize for the stupid question, but how to fix the warning about NullPointerException in this line of code
responseString = response.body().string();
.string() - Method invocation 'string' may produce 'java.lang.NullPointerException

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2018-09-17
@AndroidM

Store body in a variable and check for null.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question