Failed to resolve: com.github.PhilJay:MPAndroidChart:v2.1.4

I'm using MPAndroidChart library in android studio. But when I'm trying to sync gradle I get an error as shown in below image.

Gradle text is here to compile MPAndroidChart library.

compile 'com.github.PhilJay:MPAndroidChart:v2.1.4'

Error screenshot

How can I resolve this problem?


Add

maven { url "https://jitpack.io" }

to repositories under allprojects not under buildscript see screenshot:

enter image description here


Above solutions did not work for me. I used below to get MPAndroidChart lib working on my project.

  1. Downloaded the latest MPAndroidChart jar from: https://jitpack.io/com/github/PhilJay/MPAndroidChart/v3.0.1/MPAndroidChart-v3.0.1.jar

  2. Copied the downloaded MPAndroidChart-v3.0.1.jar file to YourProject/app/lib directory

  3. Compiled the following dependency at app level build.gradle

    dependencies {
    
        compile files('libs/MPAndroidChart-v3.0.1.jar')
    
    }
    
  4. re-sync the gradle


Putting

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

in build.gradle in app folder fixed my issue!


Go to build.gradle Add the maven { url 'https://jitpack.io' } in both buildscript{} and allprojects{} as below :

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



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

Remember to Sync.


The problem was solved after restarting Android Studio > rebuild project.