代码之家  ›  专栏  ›  技术社区  ›  Maxim Rabtsun

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

  •  300
  • Maxim Rabtsun  · 技术社区  · 8 年前

    当我跑进去的时候 调试 模式应用程序崩溃,但当我正常运行它时,它会工作。 我认为问题发生在附加调试器时。

    日志:

    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
    
    16 回复  |  直到 8 年前
        1
  •  328
  •   Jack T ifeegoo    5 年前

    对我来说,这发生在嵌套函数中有断点时。在我的情况下,它在 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(); ,在运行任何TouchEvent代码之前(在构造函数之前)。

    解决方案是移除断点(并将其放在其他位置)。

    编辑:

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

    编辑:

    另一个解决方案是禁用 快跑 但是请给 @toobsco42

        2
  •  187
  •   Etienne Lawlor    8 年前

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

        3
  •  50
  •   hcknl    8 年前

    根据谷歌开发团队的回应,该版本已于2016年1月12日确定,并将在下一版本中应用。

        4
  •  21
  •   creonilso rodrigues    7 年前

    我删除了所有的断点,并使用Emulator Pixel API 25进行了测试。

    要删除所有断点:

    • 单击下面的红色图标停止调试。

    在这篇文章中查看更多信息: https://stackoverflow.com/a/42478994/5749462

        5
  •  16
  •   flame3    7 年前

    这是由于调试点存在一些问题。删除所有调试点,然后它就可以工作了。

        6
  •  8
  •   mbpakalin    7 年前

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

        7
  •  4
  •   jujka    7 年前

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

        8
  •  3
  •   Nicoolasens    7 年前

    enter image description here

    在窗口5:调试中,使用“查看断点”按钮

    enter image description here

    取消所有的选择

    enter image description here

        9
  •  1
  •   yoAlex5    7 年前

    最简单的解决方案是: 查找其他设备或模拟器 (感谢AVD经理,我们有一个选择)这将在没有变通办法的情况下发挥魅力

        10
  •  1
  •   TDG    5 年前

    我的应用程序只有在调试模式下才会崩溃。对于3.5版本,“即时运行”被替换为“应用更改”,因此我无法禁用它。我的解决方案是正常启动应用程序(使用绿色箭头),在它崩溃的地方导航,然后将调试器连接到它:
    enter image description here

        11
  •  0
  •   Ankush    8 年前

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

        12
  •  0
  •   bartonstanley    7 年前

    遇到了同样的问题,但我的断点是嵌套函数中的第一行,因此如何将其移到其他位置?

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

    完成调试后,我删除了方法及其调用。

        13
  •  0
  •   reidisaki    7 年前

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

        14
  •  0
  •   IrvineCAGuy    7 年前

    仅在使用调试器启动时启动崩溃。重新启动Android Studio 2.3.2…一直崩溃。在运行模式下运行良好。我把它放在日志里。d()在onCreate之后…它解决了问题!想想看吧

        15
  •  0
  •   Arun Prajapati    5 年前

        16
  •  0
  •   MartianMartian    3 年前

    enter image description here

    enter image description here

    对于在上述解决方案之后仍然存在崩溃问题的任何人,以下是我在m1 mac air上所做的修复工作。

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