无法解析类 com.github.mikephil.charting.charts.BarChart、MPAndroidChart

问题描述 投票:0回答:4

发生什么事了?得到了所有指南,但我有这个错误。

  • 布局文件中引用的类,

    com.github.mikephil.charting.charts.BarChart
    ,在项目或库中找不到

  • 无法解析类 com.github.mikephil.charting.charts.BarChart

我是不是忘记了什么?是否需要更多实施?

我的项目:

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30"

    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我的模块:

dependencies {


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

我的 XML:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.github.mikephil.charting.charts.BarChart
        android:id="@+id/fragment_verticalbarchart_chart"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

我收到错误了

maven gradle android-gradle-plugin mpandroidchart android-library
4个回答
3
投票

build.gradle(:app)
中添加以下内容:

dependencies {
  //chart
  implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
  ...

}

并在

settings.gradle
添加
maven { url "https://jitpack.io" }

dependencyResolutionManagement {
 repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
 repositories {
    google()
    mavenCentral()

    maven { url "https://jitpack.io" } // add this line
 }  
}

0
投票

在settings.gradle中添加maven { url "https://jitpack.io" }。 调用菜单文件 -> 同步项目与 Gradle 文件。


0
投票

我遇到了同样的问题并通过添加

maven { url "https://jitpack.io"}
解决了它 在设置 Gradle 时效果很好


0
投票

我遇到了同样的问题,并通过在设置 Gradle 中添加 maven { url "https://www.jitpack.io"} 来修复它,并且工作正常

© www.soinside.com 2019 - 2024. All rights reserved.