in AndroidStudio or idea
- Config the application will be debug, open Edit Configurations
add "VM Options" Config
“-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005”
remember "address"
- Config Remote Debugger
if not exits, Click + to add
specify "Port" same as in Step 1 "address"