Skip to main content

Setup

Compose destinations is available via maven central.

1. Add the KSP plugin

build.gradle(:app)
plugins {
//...
id 'com.google.devtools.ksp' version '1.6.21-1.0.6' // Depends on your kotlin version
}
info

The version you chose for the KSP plugin depends on the Kotlin version your project uses.
You can check https://github.com/google/ksp/releases for the list of KSP versions, then pick the last release that matches your Kotlin version. Example: If you're using 1.6.21 Kotlin version, then the last KSP version is 1.6.21-1.0.6.

2. Add the dependencies

Compose Destinations has multiple active versions. The higher one uses the latest versions for Compose and Accompanist, while the others use only stable versions. Choose the one that matches your Compose version, considering this table:

Compose 1.1 (1.1.x)Maven Central
Compose 1.2 (1.2.x)Maven Central
Compose 1.3 (1.3.x)Maven Central
caution

If you choose a version that uses Compose with a higher version then the one you're setting for your app, gradle will upgrade your Compose version via transitive dependency.

build.gradle(:app)
implementation 'io.github.raamcosta.compose-destinations:core:<version>'
ksp 'io.github.raamcosta.compose-destinations:ksp:<version>'
info

If you want to use animations between screens and/or bottom sheet screens, replace above core dependency with:
implementation 'io.github.raamcosta.compose-destinations:animations-core:<version>'
this will use Accompanist Navigation-Animation and Accompanist Navigation-Material internally.
Read more about the next steps to configure these features here

3. And finally, you need to make sure the IDE looks at the generated folder

See KSP related issue.
Here is an example of how to do that for all your build variants:

build.gradle
android {
//...

applicationVariants.all { variant ->
kotlin.sourceSets {
getByName(variant.name) {
kotlin.srcDir("build/generated/ksp/${variant.name}/kotlin")
}
}
}
}
Important!

Replace applicationVariants with libraryVariants if the module uses 'com.android.library' plugin!