skip to Main Content

I am tried to use version catalogue with Android-Studio Iguana 2023.2.1 Patch 2.
When I try to Sync Gradle I get this error:

Invalid catalog definition:
 - Problem: In version catalog libs, you can only call the 'from' method a single time.

But I am only using it once, at least from what I understand.

This is my settings.gradle.file

pluginManagement {
    repositories {
        google {
            content {
                includeGroupByRegex("com\.android.*")
                includeGroupByRegex("com\.google.*")
                includeGroupByRegex("androidx.*")
            }
        }
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    versionCatalogs {
        libs {
            from(files("gradle/libs.versions.toml"))
        }
    }
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.name = "Emvoliasmoi"
include ':app', ':jsch-0.1.55', ':scan'

and this is my libs.version:

[versions]
kotlin="1.9.24"
realm="1.16.0"
androidApplication = "7.3.0"
appCompat = "1.1.0"
constraintLayout="2.1.4"
lifecycle = "2.3.1"
material = "1.11.0"
retrofit = "2.9.0"
gson="2.8.6"
work = "2.3.4"


[libraries]
appCompat = "androidx.appcompat:appcompat:$appCompat"
constraintLayout = "androidx.constraintlayout:constraintlayout:$constraintLayout"
lifecycleViewmodel = "androidx.lifecycle:lifecycle-viewmodel:$lifecycle"
lifecycleLivedata = "androidx.lifecycle:lifecycle-livedata:$lifecycle"
lifecycleCommonJava8 = "androidx.lifecycle:lifecycle-common-java8:$lifecycle"
material = "com.google.android.material:material:$material"
retrofit = "com.squareup.retrofit2:retrofit:$retrofit"
converter-gson = "com.squareup.retrofit2:converter-gson:$retrofit"
workRuntime = "androidx.work:work-runtime:$work"


[plugins]
androidApplication = { id = "com.android.application", version.ref = "androidApplication" }
kotlinAndroid = {id = "org.jetbrains.kotlin.android", version.ref="kotlin"}
realm = {id ="id.realm.kotlin", version.ref="realm"}

The path "gradle/libs.versions.toml" is correct relative to settings.gradle file.

An "from" is used only once.
Does any one knows what’s wrong here?

2

Answers


  1. There is no need to specifically declare the default libs.versions.toml in versionCatalogs as it would be picked by the gradle build from the gradle subdirectory, as stated in the documentation:

    Gradle offers a conventional file to declare a catalog. If a libs.versions.toml file is found in the gradle subdirectory of the root build, then a catalog will be automatically declared with the contents of this file.

    Login or Signup to reply.
  2. comment this part of the code

    //  versionCatalogs {
    //        libs {
    //           from(files("gradle/libs.versions.toml"))
    //       }
    //    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search