Crashlytics reporting multiples issues for TextView.makeSingleLayout

被刻印的时光 ゝ 提交于 2020-01-02 10:09:09

问题


I am receiving multiples crash reports about the same error, but I have no idea what is may causing it.

The exception that is throwing is ArrayIndexOutOfBoundsException in android.widget.TextView.makeSingleLayout.

I know it is not about Android versions and devices types, since it is getting reports from multiple versions and devices.

Here is what I am getting from Crashlytics:

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=125; index=-1
       at android.text.StaticLayout.calculateEllipsis(StaticLayout.java:785)
       at android.text.StaticLayout.out(StaticLayout.java:704)
       at android.text.StaticLayout.generate(StaticLayout.java:410)
       at android.text.StaticLayout.<init>(StaticLayout.java:140)
       at android.widget.TextView.makeSingleLayout(TextView.java:6199)
       at android.widget.TextView.makeNewLayout(TextView.java:6056)
       at android.widget.TextView.onMeasure(TextView.java:6432)
       at android.view.View.measure(View.java:16653)
       at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1231)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:590)
       at android.view.View.measure(View.java:16653)
       at android.widget.ListView.setupChild(ListView.java:1870)
       at android.widget.ListView.makeAndAddView(ListView.java:1793)
       at android.widget.ListView.fillDown(ListView.java:691)
       at android.widget.ListView.fillFromTop(ListView.java:752)
       at android.widget.ListView.layoutChildren(ListView.java:1616)
       at android.widget.AbsListView.onLayout(AbsListView.java:2087)
       at android.view.View.layout(View.java:14973)
       at android.view.ViewGroup.layout(ViewGroup.java:4637)
       at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:636)
       at android.view.View.layout(View.java:14973)
       at android.view.ViewGroup.layout(ViewGroup.java:4637)
       at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
       at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
       at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
       at android.view.View.layout(View.java:14973)
       at android.view.ViewGroup.layout(ViewGroup.java:4637)
       at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1167)
       at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:852)
       at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:871)
       at android.view.View.layout(View.java:14973)
       at android.view.ViewGroup.layout(ViewGroup.java:4637)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
       at android.view.View.layout(View.java:14973)
       at android.view.ViewGroup.layout(ViewGroup.java:4637)
       at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:437)
       at android.view.View.layout(View.java:14973)
       at android.view.ViewGroup.layout(ViewGroup.java:4637)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
       at android.view.View.layout(View.java:14973)
       at android.view.ViewGroup.layout(ViewGroup.java:4637)
       at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
       at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
       at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
       at android.view.View.layout(View.java:14973)
       at android.view.ViewGroup.layout(ViewGroup.java:4637)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
       at android.view.View.layout(View.java:14973)
       at android.view.ViewGroup.layout(ViewGroup.java:4637)
       at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1995)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1752)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1008)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5717)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
       at android.view.Choreographer.doCallbacks(Choreographer.java:574)
       at android.view.Choreographer.doFrame(Choreographer.java:544)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
       at android.os.Handler.handleCallback(Handler.java:733)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5127)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
       at dalvik.system.NativeStart.main(NativeStart.java)

Is there any solution for that?

I do not write a explicit implementation for TextView.makeSingleLayout.


回答1:


It has been almost a year, so my memory on this is a little fuzzy, but...

I faced what I suspect is the same problem in my own app. For me, it was happening because I was using android:ellipsize="start" without also using android:singleLine="true".

We had switched all of our android:singleLine="true" attributes to the recommended android:maxLines="1", but it turns out that there's a bug in how the system calculates the ellipsis that is triggered if singleLine isn't present.

So I believe you can solve this issue by simply adding android:singleLine="true" to your TextViews that are using ellipsize attrs.



来源:https://stackoverflow.com/questions/45487427/crashlytics-reporting-multiples-issues-for-textview-makesinglelayout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!