Android app crashes when launched in debug mode

爷,独闯天下 提交于 2019-11-26 15:43:48

For me, it occurred when I have a breakpoint in a nested function. In my case, it was within Runnable.run() {}. Not sure if it happens in other nested functions.

Example:

public class TouchEvent {
    public boolean HandleEvent(MotionEvent Event) {
        new Runnable() { @Override public void run() {
            int i=5;
            i++;
        }};
    }
}

If there is a breakpoint on any line inside the run() func, it crashes with the error A/art: art/runtime/jdwp/jdwp_event.cc:661] Check failed: Thread::Current() != GetDebugThread() (Thread::Current()=0x########, GetDebugThread()=0x########) Expected event thread .

This error occurs the first time the class is encountered, NOT when the breakpoint is hit. So it occurred for me when I stepped into a line that had new TouchEvent();, before any of the TouchEvent's code was run (before the constructor).

The solution is to remove the break point (and put it elsewhere).

Edit:

Forgot to mention, it seems to be tied to API25, but has been reported for API26 and API27 too.

Edit:

Another solution is to disabled Instant Run, but please give toobsco42 credit for that below.

In my case i had to disable Instant Run. It seems like Instant Run has all sorts of side effects and this can be one of them.

Problem is related with Android version 7.x, i removed all the breakpoints in nested functions and it worked, tested with Android version 6.0 too, and it is working without problem.

According to google developers team response, it was fixed on 12/1/2016 and will be applied in next release.

I removed all the breakpoints and it worked, tested with Emulator Pixel API 25.

To remove all breakpoints:

  • Go to Debugger option.

  • Click on red icon which is below to stop debug.

  • You will see a window there you can remove all breakpoints.

See more in this post: https://stackoverflow.com/a/42478994/5749462

This is due to some problem with debug points. Remove all the debug points and then it should work.

Its really weird, i disabled Instant Run and the problem solved itself.

My issue was that I had a breakpoint at import statement

The simplest solution is trying to find another device or emulator (thanks AVD Manager we have a choice) that will work as charm without workarounds

In the window 5 : Debug, Use the button "View Breakpoints"

UnSelectAll of them

Removing breakpoint from Runable.run() solved the issue for me. I was able to use breakpoints at runtime inside Runable.run(). But not at compile time

Ran into this same issue but my breakpoint was the first line in the nested function so how to move it elsewhere?

I created a temporary private method and made an invocation of that method the first thing in the function and then I set the breakpoint in that method.

When I finished debugging I removed the method and its invocation.

it is a long shot but for me, when I have an import statement that isn't being used, and that import has code that runs network calls, it crashed for me but when removing it, the code was able to debug normally.

Starting crashing only when starting with debugger. Restarted Android Studio 2.3.2...kept crashing. Runs fine in Run mode. I put in a Log.d() right after onCreate...and it cleared up the problem! Go figure!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!