문제상황
라이브러리를 연결하기 위해 gradle에 코드를 입력하였으나, 이러한 오류가 발생
Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'app\build.gradle'
(문제해결 전) Build gradle 코드
plugins {
id 'com.android.application'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.forcode"
minSdk 21
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
}
}
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}
dependencies {
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 코드
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
rootProject.name = "ForCode"
include ':app'
해결방법
settings.gradle에 있는
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
코드를
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
로 수정
Build Success 가 나옵니다.
'프로그래밍 언어 > Java' 카테고리의 다른 글
[Android java] Dialog 에서 MainActivity로 값 전달 (0) | 2021.11.05 |
---|---|
Android MPAndroidChart gradle 에러 (0) | 2021.11.05 |
java 5강 생성자란? (0) | 2021.11.03 |
[Android java] addTextChangedListener onText/afterText 차이 (0) | 2021.11.02 |
java 4강 this 란 무엇인가요? (0) | 2021.10.29 |