debugging – Attaching debugger to Android process automatically in Android Studio-ThrowExceptions

Exception or error:

Is there any way to configure Android Studio to attach the debugger to an android process automatically (specifically for a background process started by a service)? I want to have breakpoints stop execution in Android Studio for services that are running in a background process. I have been able to manually start a started service and attach the debugger manually to get this to work. I was just wondering if there is someway to configure Android Studio to do this automatically.

Edit: I probably should have mentioned first that I wanted to attach the debugger to a background android process created from starting or binding to a service.

How to solve:

If you have the package name, you type adb shell am set-debug-app -w packagename to let it wait until debugger connected.


You can run an app with a debugger directly attachted to it at startup by using this little button:

Android Studio menu bar

Leave a Reply

Your email address will not be published. Required fields are marked *