40

I'm experiencing a really unusual behavior:

From today (no style, Gradle or layout changes done), every-time I click on an EditText or TextInputEditText (just set focus on them), the app crashes with the following error:

java.lang.ClassCastException: java.lang.ref.SoftReference cannot be cast to android.view.inputmethod.InputConnection at com.android.tools.profiler.support.profilers.EventProfiler$InputConnectionHandler.run(EventProfiler.java:330) at java.lang.Thread.run(Thread.java:833)

I searched on the net and I didn't find anything similar and at the moment I'm really without any idea.

I tried it on two different Huawei devices with Android 6.0 and both result in a crash.

If I run it on my phone (Oneplus 3, Android 7) I have no errors and the app works correctly.

What I tried:

  • Changing the layout, one of those who were crashing
  • Adding a simple EditText with no attributes set
  • Removing all code and leaving the Activity "blank"
  • Cleaning some gradle unused references
  • Uninstalling app from phone
  • Rebooting phone
  • Invalidating

Not a single solution worked. What is happening to my application?

Thanks all

Pier Giorgio Misley
  • 5,305
  • 4
  • 27
  • 66

3 Answers3

114

I had the same issue,my mobile is also Huawei with Android 6.0.You should set up android studio and close the android profiler in Settings.I wish that can help you .

enter image description here

Pier Giorgio Misley
  • 5,305
  • 4
  • 27
  • 66
ApocalypseFire
  • 1,164
  • 1
  • 7
  • 3
  • 1
    I'm so glad I could help you, and I spent a couple of hours checking out the problem.Release apk runs without any problems on the phone. – ApocalypseFire Nov 23 '17 at 09:14
  • Funny that advanced profiling used for better tracking of memory leaks causes massive memory leaks and crashes itself. I had the same problem working on pre Oreo devices. I observed memory spikes and/or crashes, thank you for the post. – mtsahakis Mar 28 '18 at 12:52
  • Disable it, yes. It make my app crash! – careful7j Apr 27 '18 at 09:57
7

Not only open profiler can cause ClassCastException on same Huawei devices, but also it may cause

java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.view.inputmethod.InputConnection.finishComposingText()' on a null object reference

wish help you

MapleDev
  • 71
  • 1
0

I had the same issue, the full stack trace was only two lines so that I could not find more useful information.

So, I uninstalled my application from mobile, rebooted it, I also cleaned the project on Android Studio, and tried again, when I opened the activity that crashed before, it ran normally as usual. my mobile is also Huawei with Android 6.0 , I wish that can help you .

Yahya Hussein
  • 8,767
  • 15
  • 58
  • 114