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.

4

2 回答 2

8

请像这样编辑您的顶级 gradle 文件:

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

其他事情..看看android studio右下角的gradle控制台,给我看日志。

于 2016-03-25T00:51:02.010 回答
1

linux 上的 java/gradle 无法识别 ssl 证书是一个问题。最简单的解决方案是使用 java 8,请参阅https://www.jitpack.io/docs/FAQ/。我在 Debian 8.5 Jessie 上并使用 jessie/backports 的 openjdk 8(而不是 stock 7 版本)解决了我系统上的问题(构建 gnucash-android)。

于 2016-07-06T17:57:01.177 回答