'Gradle - A problem occurred evaluating root project (Android)
hello there I was trying to add this repository
allprojects {
repositories {
google()
mavenCentral()
}
}
but don't know why I'm getting this error (never happened before)
A problem occurred evaluating root project 'Dog Howl'.
> Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'
full code
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Solution 1:[1]
Ok thanks to this answer it solved my issue
in the settings.gradle
i replaced this
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
with this
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
and it solved the isuue
Solution 2:[2]
in your projects settings.gradle
add the repositories you want to
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
maven { url "https://maven.xyz.com" }
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Vasant Raval |
Solution 2 | madaraUchiha |