Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Weather App (2015) Hooking Up the Model to the View Plugging in the Data

FATAL EXCEPTION: OkHttp Dispatcher java.lang.NullPointerException

when i first added the method updateDisplay and tried to get the temperature it's just popping up this error

3 Answers

Tim Lee
Tim Lee
968 Points

So Amr, it is a little hard to pinpoint down your bug without seeing the code first hand, but I'll try my best to help you out. Getting a NullPointerException is pretty common in Android app developing and you should not worry too much. My guess is, either your method has a return value that is not set to anything(does not have a pointer to a real value) or you did not initialize a variable correctly. If you shoot over your code to me, or put your code on comment, I will be able to help you out more. You should read thoroughly the android monitor when your app is running, it usually gives you hints or locations on where you went wrong.

i managed to Solve it and let me tell the problem and how i could fix it

The problem was i didn't implement the butterknife correctly because of some error in the gradle so the thing was when i tried to set the text of the temperature the text view variable was pointing to nothing I changed the butterknife codes to normal findViewById() method so it worked fine

Anders Tofte
Anders Tofte
4,823 Points

Had the same problem. Work around butterknife did the trick. Thank's amr hossam

Michael Anderson
Michael Anderson
2,704 Points

I had the same error and stopped using Butterknife as well to get it to work.

butterknife ('com.jakewharton:butterknife:8.8.1') Android Studio 3.0.1 Build #AI-171.4443003, built on November 9, 2017 JRE: 1.8.0_152-release-915-b01 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 7 6.1