刚刚犯了一个低级错误。
引用 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
}
看来,写程序还是要细心为好,小小的一个失误有时候会让你怀疑人生。
参考
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。