Hello :wave: I’m having issue with gradle sync in ...
# gradle
z
Hello 👋 I’m having issue with gradle sync in Android Studio, I started using TOML version catalog format and inside my build.gradle.kts I always get an error:
Copy code
Caused by: ScriptCompilationException(errors=[ScriptCompilationError(message=Unresolved reference: libs, location=/Users/username/.gradle/.tmp/gradle-kotlin-dsl-8359750362388470244.tmp/build.gradle.kts (13:20)),
My gradle setup looks like this:
Copy code
plugins {
    `kotlin-dsl`
    id("com.osacky.doctor") version "0.7.0"
}

repositories {
    google()
    jcenter()
    mavenCentral()
}

dependencies {
    implementation(libs.android.gradle)
    implementation(libs.kotlin.gradle.plugin)
    implementation(libs.kotlin.serialization)
    implementation(libs.sqldelight.gradle.plugin)
}

kotlin {
    explicitApi()
}
It works completely fine if I build it from cli. Is this some known error of AS and toml version catalog compatibility or I’m doing something wrong? Gradle wrapper version: 7.1.1 AS: 2021.1.1 Canary 3
g
Might be a stupid question, but have you enabled the version catalog feature in your
settings.gradle
?
z
There are no stupid questions when it comes to gradle for me 😛 but yes, I have these 2 features enabled:
Copy code
enableFeaturePreview("VERSION_CATALOGS")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
Seems like I forgot to mention important detail 💦, the problem is happening only for the
build.gradle.kts
inside the
buildSrc
module. Other modules have no issue
g
If you’re using
buildSrc
then you need to import the catalog inside that build as well. It’s described here how to do: https://docs.gradle.org/current/userguide/platforms.html#sec:importing-catalog-from-file
z
Yeah, so I have:
Copy code
dependencyResolutionManagement {
    versionCatalogs {
        create("libs") {
            from(files("../gradle/libs.versions.toml"))
        }
    }
}
and it’s still causing the crash if I do gradle sync from AS but project builds successfully via cli
g
If CLI builds locally, then it might be a problem with Android Studio
z
Ok, will create a ticket for it 🙂
344 Views