How to debug remote AIDL service in Android?

2019-05-14 18:31发布

问题:

I have sources of a remote service which is using AIDL. Also I have my own app that connects to that service. I debug two apps simultaneously, but inside the remote service I can hit breakpoints only in generated AIDL file (stub and proxy), but I can't hit the real methods of the remote service. What can be the reason? Maybe I'm doing something wrong?

Thanks!

回答1:

It's a while since I tried this, but from memory I think what I did was :

I set the breakpoints in the source, started the app which used the remote service, then went to the DDMS perspective and selected the process corresponding to the service. Then clicked on the little green bug icon which enabled the breakpoints to trigger.



回答2:

Put this android.os.Debug.waitForDebugger() in onCreate() of the service and put a break point to a line below. Then in AS press "Attach debugger to Android Process" and double click on the service process to be debugged. New debug session will be created.