Search code examples
androidgradlempandroidchart

Android gradle problem while build with using MPAndroidChart


I am trying to use MPAndroidChart, but there is occuring build gradle problem.

I reference the github document below.

https://github.com/PhilJay/MPAndroidChart

I follow the 'Gradle Setup'

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}

This is how I put the codes

enter image description here

and when I started to build it the error code is Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'app\build.gradle'

Did I put the build code in the wrong way? or did I missed some important settings?


Solution

  • Probably, you need to append the entry, maven { ... } to the dependencyResolutionManagement.repositories clause in settings.gradle.

    app/build.gradle

    // repositories {
    //    maven { url 'https://jitpack.io' }
    // }
    

    settings.gradle

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