Migrating to Gradle Catalogs from BuildSrc in android studio -> "unknown property libraries"

I’m trying to migrate my project from BuildSrc for libraries etc to Gradles “new” Catalogs. But I keep running in to the following error when building:

Could not get unknown property ‘libraries’ for extension ‘libs’ of type org.gradle.accessors.dm.LibrariesForLibs.

Gradle 7.5.1 is running on the project.

I have created ./gradle/libs.libraries.toml which only has one library for testing and looks like this:

[libraries]
somelib = { module = "androidx.annotation:annotation", version = "1.4.0" }

and in a module build.gradle file I’m trying the following:

dependencies {
    implementation libs.libraries.somelib
}

But when building the project it keeps crashing on the implementation line saying that libraries is an unknown property. libs however is found.

I have done all the usual cleaning of the project but this persists. Suggestions?

If you manually import that libs.libraries.toml file in your settings script into the libs catalog, it would be libs.somelib.
If you did not import that file manually but wanted to use the default file, it would additionally be libs.versions.toml instead.

Thanks Björn. Tested and libs.somelib works but I find it strange as I haven’t manually imported libs.libraries.toml anywhere. I have only created the file in the gradle folder in the root of the project. I would assume that would be the default file.

Well, I guess you just mistype repeatedly here.
The default name that is considered as I said is libs.versions.toml, not libs.libraries.toml. :slight_smile:

I’m blind. I have double checked the name so many times and kept seeing it right. Thanks!