Cannot resolve class com.github.mikephil.charting.charts.BarChart when upgrading from 3.0.2 to 3.1.0

257 Views Asked by At

I'm maintaining an app written in 2019 (already used AndroidX). I'm curious what if I upgrade the MPAndroidChart from v3.0.2 to to 3.1.0?

selling_summary_activity.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    android:background="@drawable/app_background"
    tools:context=".ui.home.statistics.SellingSummaryActivity">

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

</RelativeLayout>

build.gradle (:app)

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

build.gradle (project)

buildscript {
    repositories {
        jcenter()
        google()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.2'
        classpath 'com.google.gms:google-services:4.3.10'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

plugins {
    id "org.sonarqube" version "3.3"
}

sonarqube {
    properties {
        property "sonar.projectKey", "xxxxx_for_android"
    }
}

settings.gradle

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url "https://jitpack.io" }
        jcenter()
    }
}

include ':app'

Eventually, when loading selling_summary_activity.xml, Android Studio (I'm on Flamingo) complains:

Class referenced in the layout file, com.github.mikephil.charting.charts.BarChart, was not found in the project or the libraries

Cleaning, rebuilding, invalidate caches and sync project with Gradle a few times, even restarting Android Studio doesn't solve the issue. But reverting MPAndroidChart to v3.0.2 quickly solves it. What's wrong here? Perhaps I miss some additional settings to use the latest version?

0

There are 0 best solutions below