当我在调试模式下运行时,应用程序崩溃了,但当我正常运行时,它可以工作。 我认为问题发生在附加调试器时。

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

对我来说,它发生在嵌套函数中有断点时。在我的例子中,它在runable .run(){}中。不确定是否发生在其他嵌套函数中。

例子:

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

如果在run()函数c中的任何一行上有断点,它将崩溃,并出现错误a /art: art/runtime/jdwp/jdwp_event。cc:661] Check failed: Thread::Current() != GetDebugThread() (Thread::Current()=0x########, GetDebugThread()=0x########)预期的事件线程。

此错误在第一次遇到该类时发生,而不是在遇到断点时发生。所以它发生在我步入一行,有新的TouchEvent();,在任何TouchEvent的代码运行之前(在构造函数之前)。

解决方案是删除断点(并将其放在其他地方)。

编辑:

忘记说了,它似乎与API25有关,但也有报道称它与API26和API27有关。

编辑:

另一个解决方案是禁用即时运行,但请给@toobsco42的信用如下。

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

根据谷歌开发团队的回应,它在2016年1月12日被修复,并将在下一个版本中应用。

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

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

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

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

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

当我完成调试时,我删除了该方法及其调用。

我的问题是我在import语句中有一个断点

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

删除所有断点:

进入调试器选项。 点击下面的红色图标停止调试。 您将看到一个可以删除所有断点的窗口。

更多信息请见:https://stackoverflow.com/a/42478994/5749462

这是一个很长的镜头,但对我来说,当我有一个导入语句没有被使用,并且导入有运行网络调用的代码时,它崩溃了,但当删除它时,代码能够正常调试。

仅在使用调试器启动时启动崩溃。重启Android Studio 2.3.2…持续走低。在运行模式下运行良好。我把Log.d()放在onCreate之后…这解决了问题!去图!

这是由于调试点的一些问题。删除所有的调试点,然后它应该工作。

最简单的解决方案是尝试寻找另一个设备或模拟器(感谢AVD管理器,我们有一个选择),将作为没有变通办法的魅力

在窗口5:Debug中,使用“View Breakpoints”按钮

取消其中一个

删除我的应用程序上的所有调试点工作正常 可以使用ctrl+shift+f6删除所有调试点

我的应用只有在调试模式下才会崩溃。至于3.5版本-“即时运行”被替换为“应用更改”,所以我不能禁用它。我的解决方案是正常启动应用程序(使用绿色箭头),在它曾经崩溃的地方导航,然后将调试器附加到它:

对于任何在以上解决方案之后仍然有崩溃问题的人,这里是我所做的在我的m1 MAC air上修复它的方法。

确保在开发人员选项中选择“等待调试器”,并检查其他选项,以确保它们是你想要的。