I am using Android Studio Giraffe. In that new recommended way is to use Koltin build instead of groovy. So, when I created the new project, I got both Module and Project level build.gradle.kts files highlighted in red when I opened them with libs being highlited. There is seperate Version catalog file by name libs.version.toml
Red highlight
libs.versions.toml
[versions]
com-android-application = "8.1.0-alpha11"
org-jetbrains-kotlin-android = "1.8.10"
core-ktx = "1.9.0"
junit = "4.13.2"
androidx-test-ext-junit = "1.1.5"
espresso-core = "3.5.1"
lifecycle-runtime-ktx = "2.6.1"
activity-compose = "1.7.0"
compose-bom = "2023.03.00"
[libraries]
core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" }
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" }
lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle-runtime-ktx" }
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
ui = { group = "androidx.compose.ui", name = "ui" }
ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
material3 = { group = "androidx.compose.material3", name = "material3" }
[plugins]
com-android-application = { id = "com.android.application", version.ref = "com-android-application" }
org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "org-jetbrains-kotlin-android" }
[bundles]
build.gradle.kts(Module)
plugins {
alias(libs.plugins.com.android.application)
alias(libs.plugins.org.jetbrains.kotlin.android)
}
build.gradle.kts(Project)
alias(libs.plugins.com.android.application) apply false
alias(libs.plugins.org.jetbrains.kotlin.android) apply false
}
I would also like to know more about libs.versions.toml file.
The can't be called in this context by implicit receiver
message is a known bug in Gradle that was introduced when Version Catalogs were first added in Gradle 7.2.
It will be fixed in Gradle 8.1, along with some docs that will explain the workarounds for anyone using older versions of Gradle.
Until Gradle 8.1 is released, there are two workarounds.
The warning can be safely suppressed using @Suppress("DSL_SCOPE_VIOLATION")
.
// build.gradle.kts
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.kotlin.jvm)
}
Alternatively, there's an IntelliJ plugin that will suppress the error: https://plugins.jetbrains.com/plugin/18949-gradle-libs-error-suppressor