3

Trying to install MPAndroidChart, I tried to follow the instructions in the Readme for adding the library as a gradle dependency.

EDIT: I didn't edit the top-level build.grade file, only the build.gradle file in my app directory. The latter looks like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"
    useLibrary  'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.gmail.konstantin.schubert.workload"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 7
        versionName "1.1.5"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.google.guava:guava:17.0'
    compile 'joda-time:joda-time:2.8.2'
    compile 'com.android.support:design:23.0.0'
    compile 'com.github.PhilJay:MPAndroidChart:v2.2.3'
}

As you can see, I have added the maven repository and the compile instruction in the dependencies.

However, Android Studio gives me an error:

Error:(32, 13) Failed to resolve: com.github.PhilJay:MPAndroidChart:v2.2.3

EDIT: Here are the instructions as given by JitPack: https://jitpack.io/ I believe I followed them to the letter.

What am I doing wrong? What am I forgetting?

EDIT: The question is really following the wrong lead. Looking at my gradle log, I discovered the following error:

* What went wrong:
A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not resolve com.github.PhilJay:MPAndroidChart:v2.2.3.
 Required by:
     workload:app:unspecified
  Could not GET 'https://jitpack.io/com/github/PhilJay/MPAndroidChart/v2.2.3/MPAndroidChart-v2.2.3.pom'.
     > peer not authenticated

This is a much better lead to follow and can easily be googled.

Konstantin Schubert
  • 3,242
  • 1
  • 31
  • 46

2 Answers2

8

please edit your top level gradle file like this:

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

other thing.. take a look at gradle console in the bottom right of android studio, and show me the log.

Mounir Elfassi
  • 2,242
  • 3
  • 23
  • 38
  • It now says: You must specify a URL for a Maven repository. And the IDE says it can't resolve the symbol `url`. Are you sure I need the double-nesting of `maven{ maven {..}}`? But even if I just add `maven { url "https://jitpack.io"}` into the top level gradle file, it still doesn't work. – Konstantin Schubert Mar 25 '16 at 08:54
  • 1
    please take a look at my edited answer, try to remove the double-nesting of maven.. it's working on my computer – Mounir Elfassi Mar 25 '16 at 11:12
  • As I had already mentioned in my comment, I tried this configuration as well but it still gives the original error. – Konstantin Schubert Mar 25 '16 at 14:01
  • 1
    i just successfully added the library in one of my projects, i just edited my top level gradle file like in my answer plus i have `compile 'com.github.PhilJay:MPAndroidChart:v2.2.3'` in the dependencies in App gradle. – Mounir Elfassi Mar 25 '16 at 15:03
  • 1
    please remove `repositories { maven { url "https://jitpack.io" } }` from your App gradle file – Mounir Elfassi Mar 25 '16 at 15:04
  • I'll try once I'm back to my computer. It might be that I'm having an issue with other parts of my setup. – Konstantin Schubert Mar 25 '16 at 21:52
  • Are you using Android Studio? I tried you answer on a different machine but it still doesn't work. – Konstantin Schubert Mar 27 '16 at 00:57
  • yes Android Studio 1.5.1, if you can.. create a new project and import the Library – Mounir Elfassi Mar 27 '16 at 01:00
  • Actual gradle files: [build.gradle(Link)](http://pastebin.com/i4WQBBDi) and [app/build.gradle(Link)](http://pastebin.com/PAvYvq2c) Thanks for trying to help me. – Konstantin Schubert Mar 27 '16 at 01:08
  • the files seem correct to me, just remove `repositories { mavenCentral() } ` from your App gradle.. – Mounir Elfassi Mar 27 '16 at 01:15
  • Sorry, I forgot about that. But now I removed it and it still does not work. I think I should be looking for the issue elsewhere, the configuration seems fine, as you say. Thanks for your help. – Konstantin Schubert Mar 27 '16 at 01:20
  • no problem, one last thing.. take a look at gradle console in the bottom right of android studio, and show me the log if you can – Mounir Elfassi Mar 27 '16 at 01:24
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/107442/discussion-between-konstantin-schubert-and-mounir-elfassi). – Konstantin Schubert Mar 27 '16 at 01:27
1

It is a problem with java/gradle on linux not recognizing the ssl certificate. The easiest solution is to use java 8, see https://www.jitpack.io/docs/FAQ/. I am on Debian 8.5 Jessie and using openjdk 8 (instead of the stock 7 version) from jessie/backports solved the issue (building gnucash-android) on my system.

Markus B.
  • 51
  • 1