Setup
Compose destinations is available via maven central.
1. Add the KSP plugin
- .gradle
- .gradle.kts
plugins {
//...
id 'com.google.devtools.ksp' version '1.8.10-1.0.9' // Depends on your kotlin version
}
plugins {
//...
id("com.google.devtools.ksp") version "1.8.10-1.0.9" // Depends on your kotlin version
}
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.8.10
Kotlin version, then the last KSP version is 1.8.10-1.0.9
.
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) | |
Compose 1.2 (1.2.x) | |
Compose 1.3 (1.3.x) | |
Compose 1.4 (1.4.x) | |
Compose 1.5 (1.5.x) | |
Compose 1.6 (1.6.x) | |
Compose 1.7 (1.7.x) |
If you choose a version that uses Compose with a higher version than the one you're setting for your app, gradle will upgrade your Compose version via transitive dependency.
- .gradle
- .gradle.kts
implementation 'io.github.raamcosta.compose-destinations:core:<version>'
ksp 'io.github.raamcosta.compose-destinations:ksp:<version>'
implementation("io.github.raamcosta.compose-destinations:core:<version>")
ksp("io.github.raamcosta.compose-destinations:ksp:<version>")
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
If you want to use Compose Destinations in a Wear OS app, replace above core dependency with:
implementation 'io.github.raamcosta.compose-destinations:wear-core:<version>'
this will use Wear Compose Navigation internally.
3. Kotlin version < 1.8
When using Kotlin version older than 1.8.0, you need to make sure the IDE looks at the generated folder. See KSP related issue.
How to do it depends on the AGP version you are using in this case:
Either way, replace applicationVariants
with libraryVariants
if the module uses 'com.android.library'
plugin!
- AGP 7.4.0 +
- .gradle
- .gradle.kts
applicationVariants.all { variant ->
variant.addJavaSourceFoldersToModel(
new File(buildDir, "generated/ksp/${variant.name}/kotlin")
)
}
applicationVariants.all {
addJavaSourceFoldersToModel(
File(buildDir, "generated/ksp/$name/kotlin")
)
}
- AGP < 7.4.0
- .gradle
- .gradle.kts
applicationVariants.all { variant ->
kotlin.sourceSets {
getByName(variant.name) {
kotlin.srcDir("build/generated/ksp/${variant.name}/kotlin")
}
}
}
applicationVariants.all {
kotlin.sourceSets {
getByName(name) {
kotlin.srcDir("build/generated/ksp/$name/kotlin")
}
}
}