问题
When I'm debugging and the app hits an breakpoint, I can debug normally for a while. Some time later, Android displays the ANR Dialog, but I still can debug normally.
If I don't click on the Phone's screen, it ends the debug, so I need to keep my eye on the screen when debugging and that's annoying and really wastes my time, because sometimes the dialog keeps popping every 10 seconds.
I don't know what is causing this. I tried restarting the Machine, Phone, ADB and already tried using debuggable="true" on AndroidManifest, with no success.
回答1:
Looks like the problem is with a service running in background.
My service executes a background task every 5 minutes, so if the breakpoint "pauses" the main thread, the service tries to run and show the Not Responding popup. Ten seconds later, if we are still in the breakpoint, the system shows that annoying popup over and over again.
Just to be clear, there is no problem with my service, looks like it is the way IntelliJ IDEA debugs. When i need to debug something big, I disable the Service for the debug and the popup did not appear.
I don't know if there is a way to make the IDE aware that it is not responding because we are debugging the main Thread, cause that should be the right solution.
来源:https://stackoverflow.com/questions/37256905/android-not-responding-if-debugging-if-not-in-debug-app-works-normally