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) Networking Making an HTTP GET Request with OkHttp

okHttpClient auto complete not able to fine the classes

I had sync project with gradle file but still it not able to find the class

Michael Salomon
Michael Salomon
1,356 Points

Make sure that you placed the dependency in build.gradle(Module: app) and not build.gradle(Project: Stormy). Also, in your MainActivity or the activity which you are building your request you have imported okhttp as in

import com.squareup.okhttp.OkHttpClient;

Alex Johnson
Alex Johnson
6,067 Points

I had this same problem and realized that I'd accidentally added

testCompile 'com.squareup.okhttp:mockwebserver:2.5.0'

instead of

compile 'com.squareup.okhttp:okhttp:2.5.0'

to the Gradle build file. Both compile commands are on the OkHttp Github page so you have to choose the right one (compile 'com.squareup.okhttp:okhttp:2.5.0').