Home > Enterprise >  Build was configured to prefer settings repositories over project repositories but repository '
Build was configured to prefer settings repositories over project repositories but repository '

Time:10-28

A problem occurred evaluating root project when adding allprojects{}. Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'

Here is the code in build.gradle

buildscript {
repositories {
    google()
    mavenCentral()

}
dependencies {
    classpath "com.android.tools.build:gradle:7.0.0"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
}
}

allprojects {
repositories {
    google()
    mavenCentral()
    maven { url 'https://jitpack.io' }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

CodePudding user response:

For Android Studio Arctic Fox |2020.3.1 Remove this from the build.gradle

allprojects {
repositories {
    google()
    mavenCentral()
    maven { url 'https://jitpack.io' }
}

} Go to settings.gradle and add follwing line

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
    google()
    mavenCentral()
    jcenter()
    maven { url 'https://jitpack.io' }
}

}

CodePudding user response:

For Spring Boot gradle project this one of the ways by which you can specify build.gradle

buildscript {

repositories {
    mavenCentral()
maven {
            url can be given like this "https://plugins.gradle.org/"
        }
}
dependencies {
    classpath "com.android.tools.build:gradle:7.0.0"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
}
}
  • Related