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 Getting the OkHttp Library Using Gradle

JS Park
JS Park
15,959 Points

How exactly does Gradle include 3rd party code?

Does it get the files over an Internet connection or are all 3rd party APIs included when you download or update Android Studio? I don't understand how one line of code - compile 'com.squareup.okhttp3:okhttp:3.3.1' - allows us to readily use the okhttp API.

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

There are standard repositories that the authors of 3rd party libraries publish to. The 2 current standard repositories are JCenter and Maven Central, with Android Studio defaulting to JCenter. If you open your project's build.gradle file you'll see the reference to it in:

allprojects {
    repositories {
        jcenter()
    }
}

When you sync you're gradle file it will search any configured repositories for the dependencies you add and download them over the Internet.

JS Park
JS Park
15,959 Points

So you would need to have an Internet connection in order for the gradle file to sync?