'Android app crashes when launched in debug mode
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.
Log:
A/art: art/runtime/jdwp/jdwp_event.cc:661] Check failed: Thread::Current() != GetDebugThread() (Thread::Current()=0x7f44a18400, GetDebugThread()=0x7f44a18400) Expected event thread
A/art: art/runtime/runtime.cc:422] Runtime aborting...
A/art: art/runtime/runtime.cc:422] Aborting thread:
A/art: art/runtime/runtime.cc:422] "JDWP" prio=5 tid=4 WaitingForDebuggerSend
A/art: art/runtime/runtime.cc:422] | group="" sCount=0 dsCount=0 obj=0x12c60280 self=0x7f44a18400
A/art: art/runtime/runtime.cc:422] | sysTid=24137 nice=0 cgrp=default sched=0/0 handle=0x7f4b904450
A/art: art/runtime/runtime.cc:422] | state=R schedstat=( 132066712 16401043 106 ) utm=9 stm=2 core=3 HZ=100
A/art: art/runtime/runtime.cc:422] | stack=0x7f4b80a000-0x7f4b80c000 stackSize=1005KB
A/art: art/runtime/runtime.cc:422] | held mutexes= "abort lock"
A/art: art/runtime/runtime.cc:422] native: #00 pc 000000000047e2cc /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+220)
A/art: art/runtime/runtime.cc:422] native: #01 pc 000000000047e2c8 /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+216)
A/art: art/runtime/runtime.cc:422] native: #02 pc 0000000000452434 /system/lib64/libart.so (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMap+480)
A/art: art/runtime/runtime.cc:422] native: #03 pc 00000000004403ac /system/lib64/libart.so (_ZNK3art10AbortState10DumpThreadERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEPNS_6ThreadE+56)
A/art: art/runtime/runtime.cc:422] native: #04 pc 0000000000440228 /system/lib64/libart.so (_ZNK3art10AbortState4DumpERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+668)
A/art: art/runtime/runtime.cc:422] native: #05 pc 0000000000433bfc /system/lib64/libart.so (_ZN3art7Runtime5AbortEPKc+148)
A/art: art/runtime/runtime.cc:422] native: #06 pc 00000000000e597c /system/lib64/libart.so (_ZN3art10LogMessageD2Ev+1592)
A/art: art/runtime/runtime.cc:422] native: #07 pc 00000000002f8458 /system/lib64/libart.so (_ZN3art4JDWP9JdwpState24AcquireJdwpTokenForEventEm+624)
A/art: art/runtime/runtime.cc:422] native: #08 pc 00000000002f7b1c /system/lib64/libart.so (_ZN3art4JDWP9JdwpState29SendRequestAndPossiblySuspendEPNS0_9ExpandBufENS0_17JdwpSuspendPolicyEm+248)
A/art: art/runtime/runtime.cc:422] native: #09 pc 00000000002fcb08 /system/lib64/libart.so (_ZN3art4JDWP9JdwpState16PostClassPrepareEPNS_6mirror5ClassE+1380)
A/art: art/runtime/runtime.cc:422] native: #10 pc 0000000000124a9c /system/lib64/libart.so (_ZN3art11ClassLinker11DefineClassEPNS_6ThreadEPKcmNS_6HandleINS_6mirror11ClassLoaderEEERKNS_7DexFileERKNS9_8ClassDefE+804)
A/art: art/runtime/runtime.cc:422] native: #11 pc 0000000000381d04 /system/lib64/libart.so (_ZN3artL25DexFile_defineClassNativeEP7_JNIEnvP7_jclassP8_jstringP8_jobjectS7_S7_+344)
A/art: art/runtime/runtime.cc:422] native: #12 pc 00000000001dd40c /system/framework/arm64/boot-core-libart.oat (???)
A/art: art/runtime/runtime.cc:422] at dalvik.system.DexFile.defineClassNative(Native method)
A/art: art/runtime/runtime.cc:422] at dalvik.system.DexFile.defineClass(DexFile.java:296)
A/art: art/runtime/runtime.cc:422] at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:289)
A/art: art/runtime/runtime.cc:422] at dalvik.system.DexPathList.findClass(DexPathList.java:418)
A/art: art/runtime/runtime.cc:422] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
A/art: art/runtime/runtime.cc:422] at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
A/art: art/runtime/runtime.cc:422] at com.android.tools.fd.runtime.IncrementalClassLoader.findClass(IncrementalClassLoader.java:62)
A/art: art/runtime/runtime.cc:422] at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
A/art: art/runtime/runtime.cc:422] at java.lang.ClassLoader.loadClass(ClassLoader.java:367)
A/art: art/runtime/runtime.cc:422] at java.lang.ClassLoader.loadClass(ClassLoader.java:367)
A/art: art/runtime/runtime.cc:422] at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
A/art: art/runtime/runtime.cc:422] Dumping all threads without appropriate locks held: thread list lock mutator lock
Solution 1:[1]
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.
Solution 2:[2]
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.
Solution 3:[3]
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
Solution 4:[4]
This is due to some problem with debug points. Remove all the debug points and then it should work.
Solution 5:[5]
Its really weird, i disabled Instant Run and the problem solved itself.
Solution 6:[6]
My issue was that I had a breakpoint at import statement
Solution 7:[7]
Solution 8:[8]
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
Solution 9:[9]
My app also crashed only when in debug mode. As for 3.5 version - "Instant Run" was replaced with "Apply Changes", so I could not disable it. My solution was to launch the app normally (with the green arrow), navigate just after the place it used to crash and then to attach the debugger to it:
Solution 10:[10]
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
Solution 11:[11]
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.
Solution 12:[12]
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.
Solution 13:[13]
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!
Solution 14:[14]
Delete All debug points on my application works fine you can use ctrl+shift+f6 to remove all debug points
Solution 15:[15]
for anyone who still have the crashing problem after the above solutions, here's what i have done to fix it on my m1 mac air.
Make sure the select 'wait for debugger' in developer options, and go through other options as well, to make sure they are what you want them to be.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow





