MaterialScrollBar icon indicating copy to clipboard operation
MaterialScrollBar copied to clipboard

RuntimeException when calling viewGroup.addView(scrollBarView)

Open PtiPingouin opened this issue 8 years ago • 7 comments

I jumped from 12.3.1 to 12.3.5, and now, I get "RuntimeException: Cannot make calls to a recycled instance!" when calling viewGroup.addView(scrollBarView).

java.lang.RuntimeException: Cannot make calls to a recycled instance! at android.content.res.TypedArray.hasValue(TypedArray.java:1008) at com.turingtechnologies.materialscrollbar.MaterialScrollBar.implementPreferences(MaterialScrollBar.java:190) at com.turingtechnologies.materialscrollbar.MaterialScrollBar$2.run(MaterialScrollBar.java:133) at com.turingtechnologies.materialscrollbar.MaterialScrollBar.generalSetup(MaterialScrollBar.java:244) at com.turingtechnologies.materialscrollbar.MaterialScrollBar.onAttachedToWindow(MaterialScrollBar.java:229) at android.view.View.dispatchAttachedToWindow(View.java:15509) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2916) at android.view.ViewGroup.addViewInner(ViewGroup.java:4456) at android.view.ViewGroup.addView(ViewGroup.java:4258) at android.view.ViewGroup.addView(ViewGroup.java:4198)

PtiPingouin avatar Mar 30 '17 10:03 PtiPingouin

I'm not getting a crash on the example project. Would you mind providing more of the code before and after your addView() call?

turing-tech avatar Mar 30 '17 17:03 turing-tech

The reason I'm removing / adding back the scrollbar from the viewgroup is because I never was able to just hide it (neither setVisibility(GONE) nor setScrollBarHidden(false) works for me). So the crash occurs after I removed the view once, then simply try to add it back to the same parent. Simple call to View.remove() and View.add(). Nothing fancy here.

PtiPingouin avatar Mar 30 '17 18:03 PtiPingouin

I got this issue as well

qiminl avatar May 23 '17 21:05 qiminl

Its in MaterialScrollBar.java -> generalSetup() -> a.recycle() causing the crash. Use MaterialScrollBar in xml to bypass this bug.

chanonly123 avatar May 24 '17 12:05 chanonly123

I am getting the same error for the same reason!

silent10 avatar Sep 14 '17 04:09 silent10

I have gotten several reports of setVisibility(GONE) and setScrollBarHidden(false) not working. However, I myself am unable to replicate them. A code sample from anyone having this issue would be greatly appreciated. I'll even put the lucky winner in the README ;)

turing-tech avatar Dec 31 '17 02:12 turing-tech

I'm also having this issue. In my case this always happens, when I want to enter the popup window mode on samsung devices as described here and here. Surprisingly the native Android Multi-Window-Mode (described here) works fine.

ln-12 avatar May 06 '18 08:05 ln-12