56

After updating to Android Studio 3.1 I'm facing exception when EditText in focus

E/AndroidRuntime: FATAL EXCEPTION: main
Process: <package>, PID: 18938
java.lang.StackOverflowError: stack size 8MB
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)
    at android.view.inputmethod.InputConnectionWrapper.getTextBeforeCursor(InputConnectionWrapper.java:46)

Any idea how to fix this?

Update:

After some research I found out that StackOverflowError appears with different stacktraces with simple EditText:

<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"/>

When trying to enter any symbol I get:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: <package>, PID: 21122
java.lang.StackOverflowError: stack size 8MB
    at android.view.inputmethod.InputConnectionWrapper.beginBatchEdit(InputConnectionWrapper.java:106)

When I press back:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: <package>, PID: 21280
java.lang.StackOverflowError: stack size 8MB
    at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)

Even entering text in WebView causing this error

In AS 3.0 EditText's worked normal

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Kamer358
  • 2,430
  • 2
  • 16
  • 17

5 Answers5

74

As @evi pointed out there is a bug in advanced profiling.

For now disabling it (Edit configuration settings -> Profiling -> Enable advanced profiling) prevents EditText from crashing

Update:

Fix released in Android Studio 3.1.1

Advanced profiling available once again!

Kamer358
  • 2,430
  • 2
  • 16
  • 17
  • Although my comments are being deleted (hello there, mod) this is the working solution – jujka Mar 28 '18 at 11:01
  • Thanks, this bug drive me crazy since ive installed the 3.1 release of Android Studio – Steve Mar 29 '18 at 09:22
  • 13
    Maybe it's just me, but I had trouble finding the option. Maybe it helps others. I found it under Run->Edit Configurations... (profiling tab) – Alan Todtenkopf Mar 29 '18 at 19:52
  • @AlanTodtenkopf tap on help menu and search for "Edit configuration settings" hope this helps – Abhimaan Apr 12 '18 at 06:59
  • This issue seems not to be fully fixed in 3.1.1. Relevant ticket: https://issuetracker.google.com/issues/77764953 – Marcin Jedynak May 28 '18 at 14:15
  • I am on 3.1.3 and just had this problem occur after I started targeting API 26. I'm running an API 23 emulator. Disabling the advanced profiling made it go away. – Dave Hubbard Jul 11 '18 at 16:01
7

This seems only happens on Android 6.0 devices, the EditText works fine on Android 5 and android 7 devices. Disable advanced profiling (API < 26) in the run configuration works for me.

aaronhigh
  • 91
  • 3
6

Android 5.1.1, same problem. Seems to a bug in new Android Studio. Disabling advanced profiling fixes the problem for debug build.

Roman
  • 121
  • 3
2

Faced with same EditText issues just right after update to Android Studio 3.1. Try to set debuggable false in build.gradle for debug build type. Or just switch to release build type since it's false by default. That helped in my case.

Update: Confirming that disabling advanced profiling fixed my issue as well.

0

I had the same problem, but after:

  • Deleting .idea, .gradle, gradle folder and recreate it.
  • Clean project.
  • Rebuild app.

it works for me.