Skip to content
Advertisement

FATAL EXCEPTION: OkHttp Dispatcher

I’m using the OkHttp library in my android app to make web requests to a weather API. I’ve already implemented my code and I’m getting a FATAL EXCEPTION when doing the request.

I’ve already added INTERNET permissions in my manifest too.

MainActivity.java:

JavaScript

Gradle:

JavaScript

Then, here’s the exception I’m getting:

JavaScript

I don’t know what to do at this point. I’ve read around and found a few posts regarding this topic. From what I’ve gathered, UI changes must be made in the runOnUiThread() block. But I’m not making any UI changes here in my code and I still get the exception.

I’ve also already tried putting my JSON parsing code in the runOnUiThread() and got the same FATAL EXCEPTION result. Anyone got any ideas?

Advertisement

Answer

Response body can be consumed only once. You make it twice

JavaScript

More info in docs

Advertisement