Android app crashes when launched in debug mode – Dev

The best answers to the question “Android app crashes when launched in debug mode” in the category Dev.


When I run in debug mode the app crashes, but when I just run it normally it works.
I think the problem happens when the debugger is attached.


A/art: art/runtime/jdwp/] Check failed: Thread::Current() != GetDebugThread() (Thread::Current()=0x7f44a18400, GetDebugThread()=0x7f44a18400) Expected event thread
A/art: art/runtime/] Runtime aborting...
A/art: art/runtime/] Aborting thread:
A/art: art/runtime/] "JDWP" prio=5 tid=4 WaitingForDebuggerSend
A/art: art/runtime/]   | group="" sCount=0 dsCount=0 obj=0x12c60280 self=0x7f44a18400
A/art: art/runtime/]   | sysTid=24137 nice=0 cgrp=default sched=0/0 handle=0x7f4b904450
A/art: art/runtime/]   | state=R schedstat=( 132066712 16401043 106 ) utm=9 stm=2 core=3 HZ=100
A/art: art/runtime/]   | stack=0x7f4b80a000-0x7f4b80c000 stackSize=1005KB
A/art: art/runtime/]   | held mutexes= "abort lock"
A/art: art/runtime/]   native: #00 pc 000000000047e2cc  /system/lib64/ (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+220)
A/art: art/runtime/]   native: #01 pc 000000000047e2c8  /system/lib64/ (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+216)
A/art: art/runtime/]   native: #02 pc 0000000000452434  /system/lib64/ (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMap+480)
A/art: art/runtime/]   native: #03 pc 00000000004403ac  /system/lib64/ (_ZNK3art10AbortState10DumpThreadERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEPNS_6ThreadE+56)
A/art: art/runtime/]   native: #04 pc 0000000000440228  /system/lib64/ (_ZNK3art10AbortState4DumpERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+668)
A/art: art/runtime/]   native: #05 pc 0000000000433bfc  /system/lib64/ (_ZN3art7Runtime5AbortEPKc+148)
A/art: art/runtime/]   native: #06 pc 00000000000e597c  /system/lib64/ (_ZN3art10LogMessageD2Ev+1592)
A/art: art/runtime/]   native: #07 pc 00000000002f8458  /system/lib64/ (_ZN3art4JDWP9JdwpState24AcquireJdwpTokenForEventEm+624)
A/art: art/runtime/]   native: #08 pc 00000000002f7b1c  /system/lib64/ (_ZN3art4JDWP9JdwpState29SendRequestAndPossiblySuspendEPNS0_9ExpandBufENS0_17JdwpSuspendPolicyEm+248)
A/art: art/runtime/]   native: #09 pc 00000000002fcb08  /system/lib64/ (_ZN3art4JDWP9JdwpState16PostClassPrepareEPNS_6mirror5ClassE+1380)
A/art: art/runtime/]   native: #10 pc 0000000000124a9c  /system/lib64/ (_ZN3art11ClassLinker11DefineClassEPNS_6ThreadEPKcmNS_6HandleINS_6mirror11ClassLoaderEEERKNS_7DexFileERKNS9_8ClassDefE+804)
A/art: art/runtime/]   native: #11 pc 0000000000381d04  /system/lib64/ (_ZN3artL25DexFile_defineClassNativeEP7_JNIEnvP7_jclassP8_jstringP8_jobjectS7_S7_+344)
A/art: art/runtime/]   native: #12 pc 00000000001dd40c  /system/framework/arm64/boot-core-libart.oat (???)
A/art: art/runtime/]   at dalvik.system.DexFile.defineClassNative(Native method)
A/art: art/runtime/]   at dalvik.system.DexFile.defineClass(
A/art: art/runtime/]   at dalvik.system.DexFile.loadClassBinaryName(
A/art: art/runtime/]   at dalvik.system.DexPathList.findClass(
A/art: art/runtime/]   at dalvik.system.BaseDexClassLoader.findClass(
A/art: art/runtime/]   at$DelegateClassLoader.findClass(
A/art: art/runtime/]   at
A/art: art/runtime/]   at java.lang.ClassLoader.loadClass(
A/art: art/runtime/]   at java.lang.ClassLoader.loadClass(
A/art: art/runtime/]   at java.lang.ClassLoader.loadClass(
A/art: art/runtime/]   at java.lang.ClassLoader.loadClass(
A/art: art/runtime/] Dumping all threads without appropriate locks held: thread list lock mutator lock


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.


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


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

If there is a breakpoint on any line inside the run() func, it crashes with the error A/art: art/runtime/jdwp/] 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).


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


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


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:


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.