I migrated my Gradle to Version Catalog and I want to move the Kotlin compose compiler to the libs.versions.toml as well.
This is my current declaration in the Gradle App:
composeOptions {
kotlinCompilerExtensionVersion = "1.5.11"
}
I tried to do it like this
libs.versions.toml
[versions]
kotlinComposeCompiler = "1.5.11"
build.gradle.kts (:app)
composeOptions {
kotlinCompilerExtensionVersion = "${libs.versions.kotlinComposeCompiler}"
}
But my project sometimes doesn't sync with this error:
Could not find androidx.compose.compiler:compiler:provider(?).
What is the correct way to declare Kotlin Compiler Extension version using version catalog
It looks like you've set up the version catalog correctly. This generates some code including a property libs.versions.kotlinComposeCompiler
which is of type Provider<String>
(click on it in your IDE to take a look).
Provider
is a Gradle type which is a wrapper around the version designed to help with lazy initialisation, though that is not applicable here.
To get the String
version you need from inside the Provider
, you simply call get()
on it, so you end up with:
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.kotlinComposeCompiler.get()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With