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

AndroidGradleMpandroidchartJitpack

Android Problem Overview


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?

Android Solutions


Solution 1 - Android

Add

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

to repositories under allprojects not under buildscript see screenshot:

enter image description here

Solution 2 - Android

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

Solution 3 - Android

Putting

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

in build.gradle in app folder fixed my issue!

Solution 4 - Android

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.

Solution 5 - Android

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

Solution 6 - Android

I solved this by putting maven { url 'https://jitpack.io' } inside repositories in settings.gradle

Solution 7 - Android

In Settings Gradle just add this following code:

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

Solution 8 - Android

for new android studio version set repository in setting.gladdle

repositories {
    google()
    mavenCentral()
    maven { url "https://jitpack.io" }
     // Warning: this repository is going to shut down soon
}

Solution 9 - Android

I had the same problem after adding this one in the gradle solved my problem:

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

`

Solution 10 - Android

For me the issue was resolved by placing code in below order.

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        maven { url "https://maven.google.com" }
    }
}

Solution 11 - Android

You could encounter this issue if your gradle offline mode is enabled.

turn it off in android studio, Settings > Gradle and uncheck "Offline work" and sync.

Solution 12 - Android

I had to move maven { url 'https://jitpack.io' } to be the last declaration after google(), and jcenter().

Solution 13 - Android

Or just rebuild your project. Worked for me

Solution 14 - Android

Build-> Rebuild the project, then re-sync the gradle file.

Solution 15 - Android

As the Android studio is updated so you have to control your dependency form your setting.app

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven { url 'https://jitpack.io' }
    }
}

Kindly place this line the respiratory

maven { url 'https://jitpack.io' } //as i have done above 

Solution 16 - Android

One Problem can also be, that you are behind a proxy. So there are two possibilities: Add your proxy config to android Studio, ore you can also add a gradle.properties file in your project root. there you have to enter the following credentials:

    systemProp.http.proxyPassword=
    systemProp.http.proxyHost=
    systemProp.http.proxyUser=
    systemProp.http.proxyPort=
    systemProp.https.proxyPassword=
    systemProp.https.proxyHost=
    systemProp.https.proxyUser=
    systemProp.https.proxyPort=

So the https Properties are pretty necessary. I figured out that often the repositories are available over both protocols. but sometimes only over http or https.

Solution 17 - Android

Run gradle wrapper task from command line

cd ~/AndroidStudioProject/myproject/myapp
./gradlew tasks

Solution 18 - Android

This worked for me. If your under proxy add this lines in gradle properties(project properties)

systemProp.http.proxyHost= "Your proxy"
systemProp.http.proxyPort= "Proxy port"
systemProp.https.proxyHost= "Your proxy"
systemProp.https.proxyPort= "Proxy port"

Solution 19 - Android

The JitPack repository shouldn't be under buildscripts in this case. It should be just under repositories:

Solution 20 - Android

Don't forgot jetpack.io

As you can see here on medium or here on the github you have to copy the lib of MPChart AND the Jetpack. There is no reason to fail if you do this.

Don't forgot jetpack.io

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpRaNaYView Question on Stackoverflow
Solution 1 - AndroidMaher AbuthraaView Answer on Stackoverflow
Solution 2 - AndroidNafeez QuraishiView Answer on Stackoverflow
Solution 3 - AndroidSudheesh MohanView Answer on Stackoverflow
Solution 4 - AndroidNiamatullah BakhshiView Answer on Stackoverflow
Solution 5 - AndroidpRaNaYView Answer on Stackoverflow
Solution 6 - AndroidEL TEGANI MOHAMED HAMAD GABIRView Answer on Stackoverflow
Solution 7 - AndroidSoumen DasView Answer on Stackoverflow
Solution 8 - AndroidmasokayaView Answer on Stackoverflow
Solution 9 - AndroidChinthaka DevindaView Answer on Stackoverflow
Solution 10 - AndroidJayesh NairView Answer on Stackoverflow
Solution 11 - AndroidAbhiView Answer on Stackoverflow
Solution 12 - AndroidBlagoView Answer on Stackoverflow
Solution 13 - Androidthp3loN2View Answer on Stackoverflow
Solution 14 - AndroidCaglayanSerbetciView Answer on Stackoverflow
Solution 15 - AndroidMazhar IqbalView Answer on Stackoverflow
Solution 16 - AndroidErik MuellerView Answer on Stackoverflow
Solution 17 - AndroidRobertoView Answer on Stackoverflow
Solution 18 - Androidbanoth ravinderView Answer on Stackoverflow
Solution 19 - AndroidTrần Bình MinhView Answer on Stackoverflow
Solution 20 - AndroidNicoolasensView Answer on Stackoverflow