How to debug two processes in Android?

In my application, activity starts a service that runs as a separate process, I want to debug the action, as well as the service, but the debugger does not stop at breakpoints in the service?

Thanks for the help.

+7
source share
3 answers

Temporarily make this not a separate process.

@CommonsWare

+5
source

To elaborate on other answers, you can temporarily add android.os.Debug.waitForDebugger(); into your secondary process code to make it easier.

Then just attach your debugger to the process via DDMS or IntelliJ (or whatever you use).

+5
source

You need to enable debugging for the individual process.

Open the DDMS perspective (as opposed to Debug or Java). In DDMS-> Devices, select your service process, and then click on the debug button (button with a small green error). A debug icon will appear next to your process, then you can use breakpoints in your service.

Please note that before you enable debugging, you need to wait until the remote process starts. Thus, you might want a separate process to start at boot time or set a breakpoint in the main process right after the line that starts the remote service.

Before enabling debugging:

enter image description here

After enabling debugging:

enter image description here

(of course, temporarily creating a non-remote service also works, but I had an instance where it was impractical)

+4
source

All Articles