在进行 Android 开发时,如何在 AsyncTask 中使用 Eclipse 调试器?
我正在 Eclipse 中运行 ADT(Android 开发工具),并通过在 MainMenu.oncreate(类 Activity)中放置断点来验证我的调试器是否正常工作。但是当我将它放在 AsyncTask.doInBackground
的第一行时,它永远不会命中它。我知道它正在运行,因为我在 AsyncTask
中放置了一条 Log 语句,并且它显示在 LogCat 中。任何帮助将不胜感激,因为我更喜欢调试器而不是日志记录。
我的版本:
Eclipse SDK Version: 3.6.1
Build id: M20100909-0800
I'm running ADT (Android Development Tools) in Eclipse and verified that my debugger is working by putting a breakpoint in MainMenu.oncreate (class Activity)
. But when I put it in the first line of my AsyncTask.doInBackground
, it never hits it. I know it's running because I put a Log statement in the AsyncTask
and it shows up in LogCat. Any help would be appreciated as I prefer the debugger over the logging.
My versions:
Eclipse SDK Version: 3.6.1
Build id: M20100909-0800
将以下代码片段放在
doInBackground
的开头:android.os.Debug.waitForDebugger();
然后,当您在该线程中设置断点时,Eclipse 会找到它。
Put the following code fragment in the beginning of
doInBackground
:android.os.Debug.waitForDebugger();
Then when you set a breakpoint in that thread, eclipse will find it.