Debugging a service

后端 未结 6 1356
攒了一身酷
攒了一身酷 2020-11-29 02:33

I have written a service with a remote interface and installed it on my PC\'s Eclipse AVD. I have a client test harness which starts and invokes methods in the service. Init

6条回答
  •  天命终不由人
    2020-11-29 03:06

    Some of the answers correctly mention that you'd want to insert

    android.os.Debug.waitForDebugger(); 
    

    into the first interesting method of the service. However, it's not clear from those answers, that the Android Studio debugger will not start automatically when the service is started.

    Instead, you also need to wait till the service has started, then press the button to attach to process (see screenshot for Android Studio 3.6.1 .. it is the 3rd button to the right from the debug button). You will be given a choice of processes to attach to, one of which would be the service's separate process. You can then select it to complete the process of attaching the debugger to the service.

    Edit, Aug 2020: the button icon is the same in Android Studio 4.0

提交回复
热议问题