Gradle MP 的依赖性Android图表在 Android Studio 中不工作

Gradle dependency for MPAndroidChart not working in Android Studio

尝试安装 MPAndroidChart,我尝试按照 Readme 中的说明将库添加为 gradle 依赖项。

编辑: 我没有编辑 top-level build.grade file,只编辑了我的应用程序目录中的 build.gradle 文件。后者看起来像这样:

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'
}

如您所见,我在依赖项中添加了maven仓库和编译指令。

但是,Android Studio 给我一个错误:

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

编辑:这是 JitPack 给出的说明:https://jitpack.io/ 我相信我严格遵守了他们。

我做错了什么?我忘记了什么?

编辑:这个问题真的是走错了路。查看我的 gradle 日志,我发现了以下错误:

* 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

这是一个更好的线索,可以很容易地用谷歌搜索。

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

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

其他..看看 android 工作室右下角的 gradle 控制台,然后给我看日志。

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