加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

解决 MPAndroidChart 无法引入依赖的问题

发布时间:2020-12-14 01:17:51 所属栏目:百科 来源:网络整理
导读:刚刚犯了一个低级错误。 引用 MPAndroidChart 这个开源的图表库的时候,按照官方的提示去引入依赖库,结果同步的时候,怎么都编译不过。 提示的信息就是: Failed to resolve: com.github.PhilJay:MPAndroidChart:v3.0.2 可我记得自己明明就按照配置说明进行

刚刚犯了一个低级错误。

引用 MPAndroidChart 这个开源的图表库的时候,按照官方的提示去引入依赖库,结果同步的时候,怎么都编译不过。

提示的信息就是:

Failed to resolve: com.github.PhilJay:MPAndroidChart:v3.0.2

可我记得自己明明就按照配置说明进行的配置的啊。

先看官方文档。

然后,再比较自己的配置文件。

buildscript {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

dependencies {
    compile fileTree(dir: 'libs',include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',{
        exclude group: 'com.android.support',module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.1'
    compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
    testCompile 'junit:junit:4.12'
}

初看,没有什么问题。但就是编译不通过,百思不得其解。

但是后来看到 stackoverflow 上的答案时,才明白了错误所在。

我将

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

这一句错误地放置在了 buildscript{} 中,正确的应该是这样的。

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

看来,写程序还是要细心为好,小小的一个失误有时候会让你怀疑人生。

参考

stackoverflow

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读