Search code examples
androidandroid-studioandroid-edittextandroid-gradle-pluginandroid-anr-dialog

App crashing on clicking on EditText with latest updates (gradle 4.4 - android studio 3.1)


I recently updated my android studio to version 3.1 and also my gradle to version 4.4. Since, then I have been facing this issue of app going into ANR when clicking on an EditText that should popup a soft input keyboard. On clicking on an EditText I see that there are multiple GCs that get triggered and eventually the app crashes with and ANR message saying that there is a stack overflow exceeding the size of 8 MB. Here is the crash that I see: http://crashes.to/s/77a48e5d43c. Also pasting it here:

Fatal Exception: java.lang.StackOverflowError: stack size 8MB
   at android.view.inputmethod.InputConnectionWrapper.reportFullscreenMode(InputConnectionWrapper.java:122)
   at android.view.inputmethod.InputConnectionWrapper.reportFullscreenMode(InputConnectionWrapper.java:122)
   at android.view.inputmethod.InputConnectionWrapper.reportFullscreenMode(InputConnectionWrapper.java:122)
   at android.view.inputmethod.InputConnectionWrapper.reportFullscreenMode(InputConnectionWrapper.java:122)
   at android.view.inputmethod.InputConnectionWrapper.reportFullscreenMode(InputConnectionWrapper.java:122)
   at android.view.inputmethod.InputConnectionWrapper.reportFullscreenMode(InputConnectionWrapper.java:122)
   at android.view.inputmethod.InputConnectionWrapper.reportFullscreenMode(InputConnectionWrapper.java:122)
   at android.view.inputmethod.InputConnectionWrapper.reportFullscreenMode(InputConnectionWrapper.java:122)
   at android.view.inputmethod.InputConnectionWrapper.reportFullscreenMode(InputConnectionWrapper.java:122)
   at android.view.inputmethod.InputConnectionWrapper.reportFullscreenMode(InputConnectionWrapper.java:122)
   at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:416)
   at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:135)
   at android.app.ActivityThread.main(ActivityThread.java:5268)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)

Here is a snippet of how I have used EditText:

<android.support.design.widget.TextInputLayout
    android:id="@+id/textInputLayout2"
    android:layout_width="@dimen/login_screen_elem_width"
    android:layout_height="wrap_content"
    android:layout_marginTop="24dp"
    app:layout_constraintStart_toStartOf="@+id/fbLogin"
    app:layout_constraintTop_toBottomOf="@+id/fbLogin">

    <android.support.design.widget.TextInputEditText
        android:id="@+id/etFirstName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/first_name"
        android:imeOptions="flagNoExtractUi|actionNext"
        android:inputType="textPersonName"
        android:maxLines="1"
        android:textColor="@color/secondaryTextColour"
        android:textSize="16dp" />

</android.support.design.widget.TextInputLayout>

FYI: I also face similar issue when I try to click on a text item in the my PreferenceFragmentCompat.


Solution

  • UPDATE: There is one other reason to this error, Android Profilers bug. Disabling Advanced Profiling on Profiling Tab, in Run/Debug configurations may fix it.

    Here related other answer: https://stackoverflow.com/a/49112444/3669559

    enter image description here


    You are getting java.lang.StackOverflowError which means most possibly you have calling some methods recursively and continuously. That causes infinite loop and this error.

    If you have TextWatcher or any listener like OnFocusChangeListener on this EditText, you need to check it.