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

一个人想着一个人 提交于 2019-12-24 02:40:11

问题


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.


回答1:


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


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.




回答2:


In the new release of Android Studio 3.1, there is a bug in advanced profiling.

So, You just disabling it (In menu bar Run -> Edit configurations -> Profiling -> Enable advanced profiling) prevents EditText from crashing.




回答3:


The latest version of Android Studio fixes this problem, 3.1.1. Had the problem and tested the fix myself moments ago. Hope that helps!



来源:https://stackoverflow.com/questions/49623336/app-crashing-on-clicking-on-edittext-with-latest-updates-gradle-4-4-android-s

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