MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

Getting this build error BarchartView must extend android.view.View

Open gptshubham595 opened this issue 1 year ago • 2 comments
trafficstars

Getting this issue must extend android.view.View

class BatteryChargingBarChartView : BarChart {
 //work here
}

public class BarChart extends BarLineChartBase<BarData> implements BarDataProvider {}

public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<? extends
        IBarLineScatterCandleBubbleDataSet<? extends Entry>>>
        extends Chart<T> implements BarLineScatterCandleBubbleDataProvider {}
        
 public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Entry>>> extends
        ViewGroup
        implements ChartInterface {}      

Error: BatteryChargingBarChartView must extend android.view.View [Instantiatable]
                    <com.views.common.BatteryChargingBarChartView
                    ^

   Explanation for issues of type "Instantiatable":
   Activities, services, broadcast receivers etc. registered in the manifest
   file (or for custom views, in a layout file) must be "instantiatable" by
   the system, which means that the class must be public, it must have an
   empty public constructor, and if it's an inner class, it must be a static
   inner class.

   If you use a custom AppComponentFactory to instantiate app components
   yourself, consider disabling this Lint issue in order to avoid false
   positives.

Android Jellyfish Java 17 kotlin 2.0

gptshubham595 avatar May 27 '24 07:05 gptshubham595

As of now I have added this inside app:build.gradle.kts

lint {
        disable += "Instantiatable"
        checkGeneratedSources = true
        checkDependencies = true
    }
    

gptshubham595 avatar May 27 '24 08:05 gptshubham595

I also encountered a similar problem. When I changed the original gradle script to kts

fangfengrui avatar Apr 29 '25 03:04 fangfengrui