I have lost a week (now months) trying to figure out what exactly causing this problem, but no luck:( This problem started happening in my app after a recent update, which changed the entire project from java to Kotlin.
I tried my best to replicate this exception in a device i have with Oreo(android 8) but no luck. As far as i know, i think an EditText in the app is the reason for this issue.
The exception showing in Firebase Crashlytics is
Fatal Exception: java.lang.ArrayIndexOutOfBoundsException
length=9; index=-1
android.text.DynamicLayout.getBlockIndex (DynamicLayout.java:648)
android.widget.Editor.drawHardwareAccelerated (Editor.java:1703)
android.widget.Editor.onDraw (Editor.java:1672)
android.widget.TextView.onDraw (TextView.java:7686)
android.view.View.draw (View.java:19315)
android.view.View.updateDisplayListIfDirty (View.java:18232)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4281)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4261)
android.view.View.updateDisplayListIfDirty (View.java:18181)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4281)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4261)
android.view.View.updateDisplayListIfDirty (View.java:18181)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4281)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4261)
android.view.View.updateDisplayListIfDirty (View.java:18181)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4281)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4261)
android.view.View.updateDisplayListIfDirty (View.java:18181)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4281)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4261)
android.view.View.updateDisplayListIfDirty (View.java:18181)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4281)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4261)
android.view.View.updateDisplayListIfDirty (View.java:18181)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4281)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4261)
android.view.View.updateDisplayListIfDirty (View.java:18181)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4281)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4261)
android.view.View.updateDisplayListIfDirty (View.java:18181)
android.view.ThreadedRenderer.updateViewTreeDisplayList (ThreadedRenderer.java:669)
android.view.ThreadedRenderer.updateRootDisplayList (ThreadedRenderer.java:675)
android.view.ThreadedRenderer.draw (ThreadedRenderer.java:783)
android.view.ViewRootImpl.draw (ViewRootImpl.java:3127)
android.view.ViewRootImpl.performDraw (ViewRootImpl.java:2936)
android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2474)
android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1456)
android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7072)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:916)
android.view.Choreographer.doCallbacks (Choreographer.java:728)
android.view.Choreographer.doFrame (Choreographer.java:660)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:902)
android.os.Handler.handleCallback (Handler.java:790)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loop (Looper.java:164)
android.app.ActivityThread.main (ActivityThread.java:6523)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:857)
The xml code of EditText
<EditText
android:id="@+id/txtcontent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:inputType="textMultiLine|textCapSentences"
android:textColor="?attr/tilecontentcolor"
android:minLines="7"
android:gravity="top|start"
android:hint="@string/write_here"
android:textColorHint="?attr/tilecontentcolor"
android:fontFamily="@font/lato_regular"
android:textCursorDrawable="@drawable/cursor_color"
android:background="@android:color/transparent"/>
I searched everywhere for a solution, but no luck. Some say a workaround with LAYER_TYPE_SOFTWARE
So i have tried that too
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O||Build.VERSION.SDK_INT ==Build.VERSION_CODES.O_MR1) {
txtcontent.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
}
Yes, that will stop the exception from happening, but this is making the edittext not visible to user after the editext content reaches a limit. Which is a terrible fix for my app's use case (It's a diary app).
I hope someone can give an insight to solve this. Let me know if you need more details.
from Getting android.widget.Editor.drawHardwareAccelerated (Editor.java) exception only on Android 8 and 8.1 versions
No comments:
Post a Comment