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
There is no need to specifically declare the default
libs.versions.toml
inversionCatalogs
as it would be picked by the gradle build from thegradle
subdirectory, as stated in the documentation:comment this part of the code