Manage Dependencies

Manage Dependencies

This section describes how to install and maintain your project dependencies. If you are looking for recommended libraries, see Reference > Libraries & Plugins instead.

Dependencies are managed in your build.gradle.kts file for your project.

  • If you have a single-target project, this file will be located in the project root.
  • In a multi-project setup, there may be multiples: one in the project root, and additional files in each subproject.

In the case of multiple files, all of them will be applied to the project hierarchy, i.e., they are merged by Gradle at compile-time.

Repositories

A repository is an online library of libraries. The following entry should be used:

repositories {
     mavenCentral()
}

Libraries

You can add a specific library by adding it into the dependencies section of the build.gradle.kts file. Dependencies need to be specified using a group name: module name: version number (with a colon separating each one).

dependencies {
    implementation("io.coil-kt.coil3:coil-jvm:3.0.0-alpha06")
}

The implementation keyword indicates that this dependency is required for the application to both compile and run. There are other keywords that can be used to specify different types of dependencies e.g.,

  • runtimeOnly for dependencies that are only required at runtime.
  • testImplementation for dependencies that are only required for testing.
  • api when writing libraries, to indicate that transitive dependencies need to be exported (i.e. the libraries that your dependencies require).

You should use implementation for most dependencies.

ℹ️
Read the documentation for a library before you use it! Most will have the exact dependency statement that you can copy/paste into your build.gradle.kts file.

Final Word

XKCD Dependency
https://xkcd.com/2347