记录...当我想使用某个第三方库,在我的build.gradle导入依赖时报错,始终Gradle编译不通过时

报错信息:

* Exception is:

org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'Test My Application'.

Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository 'BintrayJCenter' was added by build file 'build.gradle'

我的project build.gradle 是这样的

// Top-level build file where you can add configuration options common to all sub-projects/modules.

plugins {

id 'com.android.application' version '7.1.2' apply false

id 'com.android.library' version '7.1.2' apply false

}

repositories {

jcenter()

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

}

task clean(type: Delete) {

delete rootProject.buildDir

}

大致意思是不应该在这里配置JCenter 的repositories 配置,应该在settings repositories 里面配置。

去查了下gradle7.0版本以后,maven的配置改到在project 的settings.gradle 下配置

于是我把maven 的配置挪到:

 Sync Now 即可。于是引用的第三方的库终于不报错了。

 这是引用的是Android的一个统计图表第三方库,来自大佬的博客:Android图表控件MPAndroidChart的简单介绍(MPAndroidChart3.0)_xhu_ww的博客-CSDN博客_mpandroidchart

GitHub地址: https://github.com/PhilJay/MPAndroidChart

楼主是个小菜鸡 刚学Android,记录一下解决的办法分享给和我一样新学的xdm,错误或没说明清楚的地方因为技术水平很有限,还请不吝指教,谢谢啦!

好文阅读

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。