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

Yousif Akbar
Yousif Akbar
1,488 Points

OkHttpClient is not being shown in autocomplete and I am being told that it cannot resolve symbol 'OkHttpClient'.

The command I got off the github was testCompile 'com.squareup.okhttp3:mockwebserver:3.0.1' which is different than that mentioned in the video

1 Answer

Harry James
Harry James
14,780 Points

Hey Yousif!

MockWebServer is a testing library for web protocols, and isn't used in this project. It's easy to make the mistake of using the compile statement for MockWebServer, as it's located further down on the page:

What you want is the compile statement located above that, and at the time of writing that is:

compile 'com.squareup.okhttp3:okhttp:3.0.1'

If you also have this issue, you can find the up-to-date compile statement here under the OkHttp heading of the README - not the MockWebServer statement below it!


If you go ahead and plug this in and run a Gradle Sync, you should then be able to use the classes from the OkHttp library. Hope it helps and if you run into any more issues on the way, give me a shout and I'll be happy to help out :)

Excuse me but where can I plug that in?

Harry James
Harry James
14,780 Points

Hey Channon Hall,

It goes in your build.gradle file for the app module under dependencies { }.

Let me know if you have any issues finding this :)

Oh ok Thanks Harry!