'Failed to resolve: com.github.PhilJay:MPAndroidChart:v3.1.0

Can you explain the solution to this please?

Failed to resolve: com.github.PhilJay:MPAndroidChart:v3.1.0 Show in Project Structure dialog Affected Modules: app



Solution 1:[1]

I had the same problem. I resolved it by adding jitpack.io repository to build.gradle as follows:

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

    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.3"
        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()
      //  jcenter()
        maven {url 'https://jitpack.io'}

    }

}

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

I had previously included jcenter() to get this working but when I read that jcenter() is closing down soon I went looking for another solution. Adding jitpack has solved it.

Solution 2:[2]

Please add philjay dependency in your app level build.gradle as below:

implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'

And add these lines inside dependencyResolutionManagement to your Settings.gradle:

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2