I have an app that runs perfectly fine on a device without a debugger attached. However, I have a problem when debugging in Eclipse:
When the main thread is suspended for about 10 seconds or more (for example after hitting a breakpoint), the main thread throws a SIGABRT, apparently coming from libc.
The only explanation I could think of is that the message queue on the main thread, when not being polled, is overflowing with messages coming from another thread. However, I don't see the heap growing when the main thread is suspended. Moreover, while my app has about 20 threads between all services, content providers, broadcast receivers, http and map worker threads, etc., I can't really think of a source of any excessive messages.
So my question is: How do I fix this problem? What tools can I use and how do I go about finding what is causing my app to crash while sitting suspended in the debugger?
Edit 1:
The only thing in logcat is:
02-05 22:23:54.861: I/dalvikvm(26795): threadid=3: reacting to signal 3
02-05 22:23:54.901: D/dalvikvm(26795): threadid=1: still suspended after undo (sc=1 dc=1)
02-05 22:23:54.901: I/dalvikvm(26795): Wrote stack traces to '/data/anr/traces.txt'
02-05 22:23:58.905: A/libc(26795): Fatal signal 6 (SIGABRT) at 0x000002f5 (code=0), thread 26795 (om.myapp)
Edit 2:
Further investigation leads me to believe it is android intentionally killing my process because it mistakenly thinks the UI thread is hung. The problem is NOT in my app. So now my question is: How do I stop Android from killing my process while debugging?
android intentionally kills the process because it thinks the UI thread is hung, so its a ANR right. for debugging purposes you can,
Go to Settings -> Developer options and check Show all ANRs.
This will show an App Not Responding dialog for apps running in the background. You can click the Wait button in the dialog to prevent the system from killing your process until the debugger attaches. Note that the dialog is opened automatically for apps running in the foreground. For background apps, you have to enable this option
This started happening to me in android 7.1.1
When attaching debugger my app always crashed, same when starting app in debug mode.
What fixed it for me is simply:
- Run your app
- Click on "Mute Breakpoints" in Debug
- Attach the debugger
- Re-Click on "Mute Breakpoints" to unmute
- Done, debugging works again
I had similar issues, but what Sam suggested didn't help - I had to actually REMOVE the breakpoints and then it worked for me.
I had to reinstall android studio one time and the second time it happened it just went away by its self
来源:https://stackoverflow.com/questions/21595778/android-app-crashes-with-sigabrt-signal-6-only-while-eclipse-debugging