프로그래밍 언어/Java

[Android java]Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle' 에러 해결

happy_life 2021. 12. 14. 22:59

Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'

그래들 지옥에서 벗어나기란 쉬운 일이 아닙니다.. 저의 삽질이 여러분에게 조금이라도 도움이 되었으면 좋겠습니다.

 

build.gradle(Project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.3'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

 

 

build.gradle(Module)

plugins {
    id 'com.android.application'
}

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.example.recycleviewexample"
        minSdk 26
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    dataBinding{
        enabled = true
    }
}
repositories{
    maven { url 'https://jitpack.io' }
}
dependencies {
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
    def room_version ="2.3.0"
    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"
    implementation 'com.wdullaer:materialdatetimepicker:3.6.4'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

 

settings.gradle

 이 빨간 부분을 모두 지워주세요

 

드디어... 이 코드들을 지움으로서 그래들 지옥에서 벗어났습니다.

여러분도 모두 화이팅