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

Time:08-25

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?

CodePudding user response:

Just skip the 'libraries' part:

dependencies {
    implementation libs.somelib
}
  • Related