MPDandroidChart v3.1.0在github上找不到

vddsk6oq  于 2023-11-15  发布在  Android
关注(0)|答案(3)|浏览(141)

我试图使用Java语言在我的Android应用程序中实现MPDandroidChart,但Android Studio在同步项目时返回错误。
Cannot find com.github.PhilJay:MPDandroidChart:v3.1.0. Required by:project:app
我已经把依赖项放在我的build.gradle(app)文件中,如下所示:

dependencies {
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}

字符串
并添加了repository:

repositories {
    maven { url 'https://jitpack.io' }
}


我也试图实现所有提出的解决方案here,但无法整理出来.所以我需要帮助,请.

pgx2nnw8

pgx2nnw81#

我已经解决了这个问题,按照说明后,在Github issues为这个项目要解决这个问题,你只需要添加下面的代码在您的设置.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'
}

0md85ypi

0md85ypi2#

正如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'
}


最后设置.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'

envsm3lx

envsm3lx3#

KotlinDSL用户提示。

如果您在build.gradle.kts中使用KotlinDSL并尝试添加JitPack存储库,请确保使用正确的语法。在KotlinDSL中,用途:

maven { url = uri("https://jitpack.io") }

字符串
而不是Groovy语法:

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


在KotlinDSL中使用Groovy语法可能会导致Gradle同步问题。

相关问题