Vasant Raval
Vasant Raval

Reputation: 303

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
}

Upvotes: 6

Views: 19381

Answers (1)

madaraUchiha
madaraUchiha

Reputation: 41

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" }
    }
}

Upvotes: 4

Related Questions