1

(Sorry if I'm butchering any terminology- I'm still getting the hang of Android development. Please feel free to point out my mistakes)

I'm working on a project using several Service objects which appear as separate processes which appear under the Devices window in Eclipse's DDMS perspective. In order to step through one of these, I select its row, and click on the little bug icon (its tooltip is "Debug the selected process, provided its source project is present and open in the workspace").

I'm trying to debug one of these services' instantiation code. That doesn't allow me the needed time to perform those two mouse clicks, so my pre-set breakpoints won't pause the execution where I need.

In desperation I've tried using Thread.sleep() in the Service's onCreate() method, but it's only somewhat helpful, and a nasty habit I'd rather not develop.

What's the right way to debug this sort of code?

Thanks for you help!

4

1 回答 1

1
  1. 在主进程中尽可能早地放置一个断点(可能是第一个活动或在启动时运行的服务)。
  2. 右键单击断点 --> 断点属性... --> 选择“暂停 VM”
  3. 在调试模式 (F11) 下运行您的应用程序。当它到达断点时,它应该停止其他所有操作,让您有时间单击所需进程上的调试图标。
于 2013-08-06T13:53:54.927 回答