Skip to content

Error inflating class com.github.mikephil.charting.charts.LineChart #5241

Description

@fllaryora

Summary
I am having E/AndroidRuntime: FATAL EXCEPTION Caused by: android.view.InflateException Caused by: java.lang.reflect.InvocationTargetException

Expected Behavior
This only happen when I am inflating a xml for a PDF . (it is using a background thread).
When It inflates the view normally that crash behavior does not happen (it is using the ui thread).

Device (please complete the following information):

  • Device: emulator
  • Android Version [Android R - 30 ]
  • Library Version "com.github.PhilJay:MPAndroidChart:v3.1.0"

Additional Context
`E/AndroidRuntime: FATAL EXCEPTION: pool-10-thread-1
Process: com.intecanar.ondiet, PID: 17468
android.view.InflateException: Binary XML file line #7 in com.intecanar.ondiet:layout/pdf_chart: Binary XML file line #7 in com.intecanar.ondiet:layout/pdf_chart: Error inflating class com.github.mikephil.charting.charts.LineChart
Caused by: android.view.InflateException: Binary XML file line #7 in com.intecanar.ondiet:layout/pdf_chart: Error inflating class com.github.mikephil.charting.charts.LineChart
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:852)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1004)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1121)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
at android.view.LayoutInflater.inflate(LayoutInflater.java:680)
at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
at android.view.LayoutInflater.inflate(LayoutInflater.java:479)

 Caused by: java.lang.RuntimeException: Can't create handler inside thread Thread[pool-10-thread-1,5,main] that has not called Looper.prepare()
    at android.os.Handler.<init>(Handler.java:227)
    at android.os.Handler.<init>(Handler.java:129)
    at android.view.GestureDetector$GestureHandler.<init>(GestureDetector.java:306)
    at android.view.GestureDetector.<init>(GestureDetector.java:419)
    at android.view.GestureDetector.<init>(GestureDetector.java:397)
    at com.github.mikephil.charting.listener.ChartTouchListener.<init>(ChartTouchListener.java:56)
    at com.github.mikephil.charting.listener.BarLineChartTouchListener.<init>(BarLineChartTouchListener.java:87)
    at com.github.mikephil.charting.charts.BarLineChartBase.init(BarLineChartBase.java:168)
    at com.github.mikephil.charting.charts.LineChart.init(LineChart.java:32)
    at com.github.mikephil.charting.charts.Chart.<init>(Chart.java:192)
    at com.github.mikephil.charting.charts.BarLineChartBase.<init>(BarLineChartBase.java:144)
    at com.github.mikephil.charting.charts.LineChart.<init>(LineChart.java:23)
    at java.lang.reflect.Constructor.newInstance0(Native Method) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:343) 
    at android.view.LayoutInflater.createView(LayoutInflater.java:852) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1004) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1121) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:680) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:532) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:479) 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions