skip to Main Content

community, I am trying to implement MPAndroidChart in my android app using java language but android studio returns an error when I sync the project.

Could not find com.github.PhilJay:MPAndroidChart:v3.1.0.Required by: project :app

I have already put the put de dependencies in my build.gradle(app) file like bellow:

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

and add the repository:

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

I have tried also to implement all the solutions proposed here but always error even after restarting android studio, cleaning project,…
So I need help, please.

2

Answers


  1. Chosen as BEST ANSWER

    I have solved this issue by following the instruction post in the Github issues for this project To solve this, you need just to add the bellow code in your settings.gradle

    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' } //Add this line in your settings.gradle
        }
    }
    

    And also don't forget to implement the library in you build.gradle (app level)

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

  2. As crazy4dev says

    I also have to add

    build.gradle (Project)

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        repositories {
            google()
            mavenCentral()
            maven { url 'https://jitpack.io' }
        }
        dependencies {
            classpath "com.android.tools.build:gradle:7.0.4"
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    build.gradle (Module)

    dependencies {
    
        implementation 'androidx.core:core-ktx:1.7.0'
        implementation 'androidx.appcompat:appcompat:1.4.0'
        implementation 'com.google.android.material:material:1.4.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
        implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        testImplementation 'junit:junit:4.+'
        androidTestImplementation 'androidx.test.ext:junit:1.1.3'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    
        // MPAndroidChart
        implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
    }
    

    Finaly
    settings.gradle

    import org.gradle.api.initialization.resolve.RepositoriesMode
    
    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' } //Add this line in your settings.gradle
        }
    }
    rootProject.name = "AppName"
    include ':app'
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search