question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash into RecyclerView

See original GitHub issue

I had added ChartView into recycler’s cell and received crash on cell updating.

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.ramijemli.percentagechartview.renderer.BaseModeRenderer.draw(android.graphics.Canvas)' on a null object reference at com.ramijemli.percentagechartview.PercentageChartView.onDraw(PercentageChartView.java:186) at android.view.View.draw(View.java:15114) at android.view.View.updateDisplayListIfDirty(View.java:14048) at android.view.View.getDisplayList(View.java:14071) at android.view.View.draw(View.java:14838) at android.view.ViewGroup.drawChild(ViewGroup.java:3404) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.updateDisplayListIfDirty(View.java:14043) at android.view.View.getDisplayList(View.java:14071) at android.view.View.draw(View.java:14838) at android.view.ViewGroup.drawChild(ViewGroup.java:3404) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.draw(View.java:15117) at android.widget.FrameLayout.draw(FrameLayout.java:592) at android.view.View.updateDisplayListIfDirty(View.java:14048) at android.view.View.getDisplayList(View.java:14071) at android.view.View.draw(View.java:14838) at android.view.ViewGroup.drawChild(ViewGroup.java:3404) at androidx.recyclerview.widget.RecyclerView.drawChild(RecyclerView.java:4936) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.draw(View.java:15117) at androidx.recyclerview.widget.RecyclerView.draw(RecyclerView.java:4335) at android.view.View.updateDisplayListIfDirty(View.java:14048) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ThreadedRenderer.updateViewTreeDispl

xml:

<com.ramijemli.percentagechartview.PercentageChartView android:id="@+id/dogProgressView" android:layout_width="40dp" android:layout_height="40dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginRight="10dp" app:pcv_mode="ring" app:pcv_orientation="counter_clockwise" app:pcv_animDuration="400" app:pcv_textColor="@color/darkGray" app:pcv_textSize="10sp" app:pcv_animInterpolator="linear" app:pcv_backgroundBarColor="@color/peachyPinkTranparent" app:pcv_progressColor="@color/peachyPink" app:pcv_textStyle="bold" app:pcv_progressBarThickness="4dp" app:pcv_backgroundBarThickness="4dp" app:pcv_startAngle="135"/>

First time Chart draws as expected but crash performs on cell updating. Tested on API 28 and 21.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:12

github_iconTop GitHub Comments

3reactions
igorka48commented, Jul 29, 2019

I found temporary workaround by removing PercentageChartView in onViewDetachedFromWindow and adding in onViewAttachedToWindow. But It lose state and you need keep in manually.

override fun onViewDetachedFromWindow(holder: HomeAdapterHolder) {
      holder.onViewDetachedFromWindow()
      super.onViewDetachedFromWindow(holder)
  }

  override fun onViewAttachedToWindow(holder: HomeAdapterHolder) {
      super.onViewAttachedToWindow(holder)
      holder.onViewAttachedToWindow()
  }

I hope that @RamiJ3mli will find more elegant solution

0reactions
koral--commented, Jan 3, 2021

Here is my workaround: https://jitpack.io/#DroidsOnRoids/PercentageChartView/5a6836bd0d

PS Comments like:

I have the same issue

won’t help anybody.

Read more comments on GitHub >

github_iconTop Results From Across the Web

App crash on using RecyclerView - Stack Overflow
This issue occurs when no LayoutManager was provided for the RecyclerView. Change your code, and move the layoutManager setup to ...
Read more >
Bug: RecyclerView can cause a crash when its parent ...
1. ConstraintLayout that has RecyclerView in it. 2. The ConstraintLayout is inside ViewAnimator. 3. RecyclerView gets its data changed, animating items
Read more >
App crashing when trying to use RecyclerView on android 5.0
Android : App crashing when trying to use RecyclerView on android 5.0 [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] ...
Read more >
RecyclerView keeps crashing : r/androiddev - Reddit
The error happens whenever notifyDataSetChanged() is called at any point in time. There doesn't even have to be a change in the data...
Read more >
RecyclerView crashing in some circumstances #240 - GitHub
I have been experimenting with "com.google.android:flexbox:0.3.0-alpha2" with a view to adding it to my photo app as an alternative way of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found