Debugger disconnecting in Android Studio when debugging a home screen widget
Have you tried disabling the Instant run on Android Studio. May be that is conflicting while debugging.
This is not a solution to stop the detaching. But you can re-attach the debugger directly afterwards. You can attach the debugger to running processes with the button in the toolbar:
I know that it is not ideal, but maybe it is already enough to continue debugging for you.
Use this plugin of Android studio. ADB WIFI
Connect both devices 1) PC/Laptop 2) Mobile on the same network and do this Tools -> Android -> ADB WIFI -> ADB USB to WIFI.
Thanks
I went to the emulated device's Settings -> Developer Options and enabled "Show all ANRs" and now a warning appears "Your application is not responding" and I can tap "WAIT" and it seems to work.