社区中,我试图使用java语言在我的安卓应用程序中实现MPAndroidChart,但是android在同步项目时会返回一个错误。
找不到com.github.PhilJay:MPAndroidChart:v3.1.0.Required : project :app
我已经将put de依赖项放在我的build.gradle(app)文件中,如下所示:
dependencies {
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}
并添加存储库:
repositories {
maven { url 'https://jitpack.io' }
}
我也试图实现所有的解决方案提出的这里,但始终错误,即使在重启安卓工作室,清洁项目,……所以我需要帮助拜托。
发布于 2021-12-12 10:56:47
为了解决这个问题,我按照Github问题中的指令来解决这个问题,您只需要在您的settings.gradle中添加下面的代码
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url 'https://jitpack.io' } //Add this line in your settings.gradle
}
}
还不要忘记在您的build.gradle (应用程序级别)中实现库。
dependencies {
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}
发布于 2022-01-12 00:15:21
正如crazy4dev所说
我还得加上
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.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (模块)
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// MPAndroidChart
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}
最后settings.gradle
import org.gradle.api.initialization.resolve.RepositoriesMode
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url 'https://jitpack.io' } //Add this line in your settings.gradle
}
}
rootProject.name = "AppName"
include ':app'
https://stackoverflow.com/questions/70322414
复制相似问题