条形图不工作(无法解析类.....charts.BarChart)
Posted
技术标签:
【中文标题】条形图不工作(无法解析类.....charts.BarChart)【英文标题】:Barchart not working (Cannot resolve class .....charts.BarChart) 【发布时间】:2021-10-17 04:50:18 【问题描述】:构建:gradle
plugins
id 'com.android.application'
android
compileSdk 30
defaultConfig
applicationId "com.group10.chart"
minSdk 21
targetSdk 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
compileOptions
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
dependencies
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
构建: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.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
task clean(type: Delete)
delete rootProject.buildDir
activity_main
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_
android:layout_
tools:context=".MainActivity">
<!--Ui component for our bar chart-->
<com.github.mikephil.charting.charts.BarChart
android:id="@+id/idBarChart"
android:layout_
android:layout_ />
</RelativeLayout>
我不知道缺少什么,但这条线显示 无法解析类 com.github.mikephil.charting.charts.BarChart
我尝试了什么
-
它是一个 MPchart
我尝试使用 graphview,它工作得非常完美,但我想使用我项目中的条形图,我使用的是 Android Studio Articfox 版本
谢谢你帮助我
【问题讨论】:
【参考方案1】:遇到了同样的问题,解决了。 在“settings.gradle”中
将以下行添加到存储库中
maven url "https://jitpack.io"
所以它应该是这样的:
dependencyResolutionManagement
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories
google()
mavenCentral()
maven url "https://jitpack.io"
// Warning: this repository is going to shut down soon
rootProject.name = "GraphViewExample"
include ':app'
【讨论】:
以上是关于条形图不工作(无法解析类.....charts.BarChart)的主要内容,如果未能解决你的问题,请参考以下文章