gpt4 book ai didi

android - android.graphics.Paint.getTextRunAdvances 处的 IndexOutOfBoundsException(Paint.java :1774)

转载 作者:行者123 更新时间:2023-12-03 20:21:33 26 4
gpt4 key购买 nike

在我的应用程序中,用户之一有时会出错并且应用程序崩溃。用户向我发送日志:

java.lang.IndexOutOfBoundsException
at android.graphics.Paint.getTextRunAdvances(Paint.java:1774)
at android.graphics.Paint.getTextRunAdvances(Paint.java:1747)
at android.text.MeasuredText.addStyleRun(MeasuredText.java:164)
at android.text.MeasuredText.addStyleRun(MeasuredText.java:204)
at android.text.StaticLayout.generate(StaticLayout.java:281)
at android.text.DynamicLayout.reflow(DynamicLayout.java:332)
at android.text.DynamicLayout.<init>(DynamicLayout.java:176)
at android.widget.TextView.makeSingleLayout(TextView.java:6089)
at android.widget.TextView.makeNewLayout(TextView.java:5987)
at android.widget.TextView.onMeasure(TextView.java:6344)
at android.view.View.measure(View.java:15479)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
at android.view.View.measure(View.java:15479)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4826)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1038)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:576)
at android.view.View.measure(View.java:15479)
at android.widget.ListView.setupChild(ListView.java:1847)
at android.widget.ListView.makeAndAddView(ListView.java:1772)
at android.widget.ListView.fillDown(ListView.java:672)
at android.widget.ListView.fillSpecific(ListView.java:1330)
at android.widget.ListView.layoutChildren(ListView.java:1600)
at android.widget.AbsListView.onLayout(AbsListView.java:2300)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1388)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at com.slidingmenu.lib.CustomViewAbove.onLayout(CustomViewAbove.java:481)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1986)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1807)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4454)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)

如我所见,错误不是发生在我的代码中,而是发生在 android 代码中。但是用户说该错误仅发生在我的应用程序中。我该如何解决?如何理解这次崩溃的原因?

最佳答案

我通过删除 textAllCaps 解决了它

android:textAllCaps="true"

我的代码是
        <EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:maxLines="1"
android:textSize="16dp"
android:background="@drawable/edit_text_background"
android:textColor="@color/colorPrimaryDark"
android:id="@+id/nameEditText"
/>

关于android - android.graphics.Paint.getTextRunAdvances 处的 IndexOutOfBoundsException(Paint.java :1774),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17671876/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com