Android Studio Debugger Application Crashes with InterruptedException
Asked Answered
A

5

27

While working today, it seemed as if suddenly I could no longer debug our application. The funny thing is, if I ran the app normally it would work just fine. To clarify, I was running the debugger all morning without incident (apart from the occasional glitch or crash). Then after lunch it began failing 100% of the time. Of course, I've been making changes all day, hence the "it seems" above. So, here are some relevant details:

  • Android Studio 2.1.1 (April 28, 2016 build)

  • This app starts up with a log in screen. The user must then authenticate with a username/password which calls out to an external service.

  • I can get to the login screen, but the app would always crash at the same point in the middle of the authentication.

Here is the stack trace:

05-24 14:56:25.764 2399-2745/com.mycomp.myapp.test E/Crashlytics: Failed to execute task.
                    java.lang.InterruptedException
                        at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:375)
                        at java.util.concurrent.FutureTask.get(FutureTask.java:162)
                        at com.crashlytics.android.v.a(SourceFile:1936)
                        at com.crashlytics.android.v.uncaughtException(SourceFile:307)
                        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
                        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
05-24 14:56:25.764 2399-2745/com.mycomp.myapp.test E/AndroidRuntime: FATAL EXCEPTION: pool-5-thread-1
                       Process: com.mycomp.myapp.test, PID: 2399
                       java.lang.InterruptedException
                           at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:1991)
                           at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2025)
                           at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
                           at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035)
                           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097)
                           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                           at java.lang.Thread.run(Thread.java:820)

Here are the things I've tried to fix it:

  • Back out all my changes (git stash)
  • Uninstall application from phone
  • Do a clean build
  • Do a Gradle Project Resync
  • Remove all breakpoints (seriously?)
    • Ok, I've been adding breakpoints all over to see how things work, so who knows? There's some merit there.
  • Restart Android Studio! (turn it off and on again)

And so far, nothing works. However, I can't emphasize enough that if I just run the app (play button, ^R) and run it on the very same device, it works just fine! Log in with no problem. So, it doesn't seem to be a code problem.

Furthermore, if you look at the stack trace, there is nothing pointing to our project.

Any ideas?

Annadiane answered 24/5, 2016 at 20:26 Comment(0)
A
45

Well, I figured it out. It turns out I had a "Java Field Watchpoint" selected with "Suspend Thread" as one of the options. See the attached screenshot for clarification. Takeaways:

As you can see, I had been using a bunch of breakpoints, so it got buried in the window and I didn't see it.

I still don't know how it got set. I had been using watches on a previous day, but I had deleted them all. Furthermore, I'm quite certain I didn't turn it on, so how it mysteriously stopped working in the middle of the day is still a mystery. Also, I certainly wouldn't have checked "suspend thread" on my own. Some sort of default setting?

Point remains - if you are seeing weird stack traces, it might be good to check all the breakpoints and watch point settings.

I hope this helps someone.

Screenshot of BreakPoint Window in Android Studio

Annadiane answered 25/5, 2016 at 15:49 Comment(6)
I have very similar problem! Except I don't use Watchpoints - just breakpoints. Everything was working and suddenly started crashing on splash screen in my app (where I had only Thread.sleep(3000)). It started crashing after I've added one breakpoint on fragment it didn't even reach on crash, but when I've removed this breakpoint it started working again.Appreciate
wtf! i has a few breakpoints and app started crashing when launched. Removed them and everythings fine now! Wasted a good 2 hours on this shit.Jagir
@PrasadPawar - I understand. That was my reaction too. I hope you found this post before too much time went by!Annadiane
Same here with Android Studio 2.3.3. For me, it happened only with breakpoints, and like others reported, disabling breakpoints resolved the issue (and basically made running the debugger pointless). If I happen to discover something more definitive regarding this I'll provide an answer but for now, at least I can confirm that having breakpoints is at least part of the problem.Clamshell
anyone else figure this out?? I cannot run the code with breakpoints.Exum
Still happening in version 3.1.3 No one knows how to fix this? I need these breakpoints.Decurion
C
24

Instant Run appears to be the culprit (at least in my case with Android Studio 2.3.3). Instead of disabling breakpoints, try disabling Instant Run. Once I did this, breakpoints ceased to cause crashes.

See Android app crashes when launched in debug mode for details. Under Mac OS X, I disabled Instant Run by going to Android Studio->Preferences->Build, Execution, Deployment->InstantRun and unchecking "Enable Instant Run to hot swap ...".

There is a "Having trouble with Instant Run?" message displayed in the settings panel. I clicked on "Re-enable and activate extra logging", reproduced the crash, and then immediately reported using the "Help - Report Instant Run Issue..." option as they requested.

Clamshell answered 16/7, 2017 at 1:19 Comment(6)
This problem still exists in Android Studio 3.0 on Mac.Manofwar
This hit me as well in Android Studio 3.0.1 on Mac. Disabled Instant Run and could attach the debugger without crashing the app.Greenway
@Manofwar Android studio 3.0 ^ version tooBunt
It is still happening on AndroidStudion 3.1.3 on Windows as well. Turning of instant run hot swap didn't work for me.Decurion
This didn't work for me with Android Studio 3.1.4 on Mac.Arreola
This fixed the problem for me on Mac (AS 3.2.1, Built on Oct 9, 2018, macOS 10.14.1)Sidestep
S
3

Turn off instant run, It'll fix all the issues

Seals answered 7/9, 2018 at 6:16 Comment(2)
what is instant run please?Lao
How can I turn that off?Basidiospore
A
3

I changed emulators (from Android 8.1 to Android 7.0) and did not experience this again. I wasted 3 hours on this. I hope I help someone by suggesting this.

Absurdity answered 26/10, 2018 at 21:21 Comment(1)
what if this happens to device?Lao
J
0

I had the same issue today. And finally after several hours of trying to find a solution got the reason. I am currently working with multiple threads, and the breakpoints were set to "all" instead of "thread". I'm not certain, but it seemed like it somehow interfered when an activity is changed and blocked the creation of the new activity. Once I switched it to "thread", NO MORE ERRORS!enter image description here

Johnsson answered 10/7, 2023 at 7:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.