75

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?

Usama Abdulrehman
  • 1,041
  • 3
  • 11
  • 21
pRaNaY
  • 24,642
  • 24
  • 96
  • 146
  • 9
    Have you added `maven { url "https://jitpack.io" }` to your repositories? – Andrew Brooke Sep 22 '15 at 13:58
  • 1
    Just adding to @AndrewBrooke comment, you should go to your project gradle.build and add this line on repository: maven { url "https://jitpack.io" }. My project is like this: allprojects { repositories { jcenter() maven { url "https://jitpack.io" } } } – filipe.costa01 Sep 22 '15 at 14:12
  • Yes there is. and i also can't find search result for _com.github.PhilJay:MPAndroidChart_ in Choose library dependancy in Project sturucture --> app --> Dependancy --> +(add) --> Choose library dependacy search – pRaNaY Sep 22 '15 at 14:13

20 Answers20

256

Add

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

to repositories under allprojects not under buildscript see screenshot:

enter image description here

lasec0203
  • 2,422
  • 1
  • 21
  • 36
Maher Abuthraa
  • 17,493
  • 11
  • 81
  • 103
19

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

Draken
  • 3,134
  • 13
  • 34
  • 54
Nafeez Quraishi
  • 5,380
  • 2
  • 27
  • 34
14

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.

Niamatullah Bakhshi
  • 1,445
  • 16
  • 27
13

Putting

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

in build.gradle in app folder fixed my issue!

Sudheesh Mohan
  • 2,560
  • 3
  • 21
  • 38
11

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

Arda Çebi
  • 1,705
  • 4
  • 15
  • 27
pRaNaY
  • 24,642
  • 24
  • 96
  • 146
9

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

8

In Settings Gradle just add this following code:

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}
Soumen Das
  • 1,292
  • 17
  • 12
8

for new android studio version set repository in settings.gradle file

repositories {
    google()
    mavenCentral()
    maven { url "https://jitpack.io" }
     // Warning: this repository is going to shut down soon
}
Zainal Fahrudin
  • 536
  • 4
  • 23
masokaya
  • 589
  • 4
  • 10
5

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

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

`
pRaNaY
  • 24,642
  • 24
  • 96
  • 146
Chinthaka Devinda
  • 997
  • 5
  • 16
  • 36
5

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" }
    }
}
Jayesh Nair
  • 51
  • 1
  • 4
2

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.

Abhi
  • 398
  • 1
  • 11
2

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

Blago
  • 4,697
  • 2
  • 34
  • 29
  • No need for changing the order. IN my case this worked. allprojects { repositories { maven { url 'https://jitpack.io' } jcenter() google() } } – Ajay B Apr 25 '19 at 16:11
2

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 
Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
Mazhar Iqbal
  • 813
  • 7
  • 7
1

Or just rebuild your project. Worked for me

thp3loN2
  • 27
  • 2
1

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

0

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.

Erik Mueller
  • 330
  • 4
  • 10
0

Run gradle wrapper task from command line

cd ~/AndroidStudioProject/myproject/myapp
./gradlew tasks
Roberto
  • 4,524
  • 1
  • 38
  • 30
0

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"
banoth ravinder
  • 1,314
  • 15
  • 18
0

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

0

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

Nicoolasens
  • 2,871
  • 17
  • 22