我想在我的项目中使用 MPAndroidChart。
我在我的 gradle 中添加了该库,但在我的 xml 布局文件中,我找不到图表。
我的 build.gradle(Module) 是这样的:
dependencies {
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}
build.gradle(项目)是这样的:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
在
setting.gradle文件中添加
maven { url 'https://jitpack.io' }
,而不是 build.gradle(Project)
需要在setting.gradle中添加maven url,添加这样的代码。
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
对我来说,语法是不同的,所以对于任何其他未来面临同样错误的人来说。我收到错误意外的标记(使用“;”分隔同一行上的表达式)。解决办法是:
maven { url = uri("https://jitpack.io") }