Android应用程序在debugging模式下启动时崩溃

当我在debugging模式下运行的应用程序崩溃,但是当我只是正常运行它的工作。 我认为当debugging器被连接时,问题就会发生。

日志:

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 

对我来说,当我在嵌套函数中有一个断点时就发生了。 在我的情况下,它在Runnable.run(){}。 不知道是否在其他嵌套函数中发生。

例:

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

如果在run()函数内部的任何一行上都有一个断点,那么它会崩溃,出现错误A/art: art/runtime/jdwp/jdwp_event.cc:661] Check failed: Thread::Current() != GetDebugThread() (Thread::Current()=0x########, GetDebugThread()=0x########) Expected event thread

遇到类时第一次发生此错误,而不是在发生断点时。 所以当我走进一条有new TouchEvent();行的时候,它就发生了new TouchEvent(); ,在任何TouchEvent代码运行之前(在构造函数之前)。

解决办法是删除中断点(并放在其他地方)。

编辑:

忘了提及,它似乎被绑定到API25

在我的情况下,我不得不禁用即时运行。 Instant Run似乎有各种各样的副作用,这可能就是其中之一。

问题与Android版本7.x有关,我删除了嵌套函数中的所有断点,它也工作,也使用Android 6.0版进行testing,并且工作没有问题。

根据谷歌开发团队的反应,这是固定在2016年12月1日,将在下一个版本中应用。

我删除了所有的断点,它的工作,与模拟器像素API 25testing。

要删除所有断点:

  • 转到debugging器选项。

  • 点击下面的红色图标停止debugging。

  • 你会看到一个窗口,你可以删除所有的断点。

看到更多的这个职位: https : //stackoverflow.com/a/42478994/5749462

它真的很奇怪,我禁用即时运行和问题解决自己。

我的问题是我在导入语句有一个断点

从Runable.run()中删除断点解决了我的问题。 我能够在Runable.run()的运行时使用断点。 但不是在编译时

进入同样的问题,但我的断点是嵌套函数的第一行,所以如何将其移动到其他地方?

我创build了一个临时私有方法,并在该方法中首先调用了该方法,然后在该方法中设置了断点。

当我完成debugging时,我删除了方法和它的调用。

这对我来说是一个很长的路要走,但是对于我来说,当我有一个没有被使用的导入语句,并且导入有运行networking调用的代码时,它对我来说是崩溃的,但是当它被删除时,代码能够正常debugging。

仅在使用debugging器开始时才会崩溃。 重新启动Android Studio 2.3.2 …不断崩溃。 在运行模式下运行良好。 我在onCreate之后立即添加一个Log.d(),并清除了问题! 去搞清楚!