java - Android: ArithmeticException in StaggeredGridLayoutManager -
my app works fine android versions. but, in crashlytics , in devices, have crash: "java.lang.arithmeticexception: divide zero". (if not always) in android 4.x.
i have staggeredgridlayoutmanager in recyclerview (superrecyclerview).
stack trace:
fatal exception: java.lang.arithmeticexception: divide 0 @ android.support.v7.widget.staggeredgridlayoutmanager.updatemeasurespecs(staggeredgridlayoutmanager.java:922) @ android.support.v7.widget.staggeredgridlayoutmanager.onlayoutchildren(staggeredgridlayoutmanager.java:665) @ android.support.v7.widget.staggeredgridlayoutmanager.onlayoutchildren(staggeredgridlayoutmanager.java:600) @ android.support.v7.widget.recyclerview.dispatchlayoutstep2(recyclerview.java:3374) @ android.support.v7.widget.recyclerview.dispatchlayout(recyclerview.java:3183) @ android.support.v7.widget.recyclerview.onlayout(recyclerview.java:3627) @ android.view.view.layout(view.java:14102) @ android.view.viewgroup.layout(viewgroup.java:4662) @ android.support.v4.widget.swiperefreshlayout.onlayout(swiperefreshlayout.java:630) @ android.view.view.layout(view.java:14102) @ android.view.viewgroup.layout(viewgroup.java:4662) @ android.widget.relativelayout.onlayout(relativelayout.java:948) @ android.view.view.layout(view.java:14102) @ android.view.viewgroup.layout(viewgroup.java:4662) @ android.widget.framelayout.onlayout(framelayout.java:448) @ android.view.view.layout(view.java:14102) @ android.view.viewgroup.layout(viewgroup.java:4662) @ android.support.design.widget.coordinatorlayout.layoutchild(coordinatorlayout.java:1142) @ android.support.design.widget.coordinatorlayout.onlayoutchild(coordinatorlayout.java:836) @ android.support.design.widget.coordinatorlayout.onlayout(coordinatorlayout.java:850) @ android.view.view.layout(view.java:14102) @ android.view.viewgroup.layout(viewgroup.java:4662) @ android.support.v4.view.viewpager.onlayout(viewpager.java:1799) @ android.view.view.layout(view.java:14102) @ android.view.viewgroup.layout(viewgroup.java:4662) @ android.widget.relativelayout.onlayout(relativelayout.java:948) @ android.view.view.layout(view.java:14102) @ android.view.viewgroup.layout(viewgroup.java:4662) @ android.widget.framelayout.onlayout(framelayout.java:448) @ android.view.view.layout(view.java:14102) @ android.view.viewgroup.layout(viewgroup.java:4662) @ android.widget.linearlayout.setchildframe(linearlayout.java:1655) @ android.widget.linearlayout.layoutvertical(linearlayout.java:1513) @ android.widget.linearlayout.onlayout(linearlayout.java:1426) @ android.view.view.layout(view.java:14102) @ android.view.viewgroup.layout(viewgroup.java:4662) @ android.widget.framelayout.onlayout(framelayout.java:448) @ android.view.view.layout(view.java:14102) @ android.view.viewgroup.layout(viewgroup.java:4662) @ android.widget.linearlayout.setchildframe(linearlayout.java:1655) @ android.widget.linearlayout.layoutvertical(linearlayout.java:1513) @ android.widget.linearlayout.onlayout(linearlayout.java:1426) @ android.view.view.layout(view.java:14102) @ android.view.viewgroup.layout(viewgroup.java:4662) @ android.widget.framelayout.onlayout(framelayout.java:448) @ android.view.view.layout(view.java:14102) @ android.view.viewgroup.layout(viewgroup.java:4662) @ android.view.viewrootimpl.performlayout(viewrootimpl.java:2019) @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1840) @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1135) @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:4579) @ android.view.choreographer$callbackrecord.run(choreographer.java:725) @ android.view.choreographer.docallbacks(choreographer.java:555) @ android.view.choreographer.doframe(choreographer.java:525) @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:711) @ android.os.handler.handlecallback(handler.java:615) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:4935) @ java.lang.reflect.method.invokenative(method.java) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1038) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:805) @ dalvik.system.nativestart.main(nativestart.java)
i don't know kind of information needed approach problem, please ask me whatever need can update question.
saw it, too, on android 5 , 7 well. checked code , apparently crashes when mspancount 0. unlike gridlayoutmanager
, staggeredgridlayoutmanager
's setspancount
doesn't check whether it's 1 or greater, , crashes later. in case, span count 0 because made depend on screen size, seems 0 in rare cases.
Comments
Post a Comment