On Android Studio desktop, click on "Select Run/Debug Configuration" button (one with an android icon), you should be able to select the correct option.
I've had this “Socket closed” error for several weeks and it was driving me slightly mad. Today I discovered that although launching via the debug icon still gives me a “Socket closed” if I attach the debugger afterwards it works (in screenshot). Hope it saves someone else time.
I was able to fix this issue by selecting the "app" configuration. In the above screen shot the pull down to the left of the run button allows you to select the configuration.Select one without the brackets.
I was getting this error on linux, and the problem was that the another previous process have taken the port and hung. So, the solution is a netstat to locate the process blocking the port, then kill this process, or you can restart the machine.
To avoid this problem and actually launching from within Android Studio, I had to explicitly switch the build variant I was operating in (via the panel that pops up when selecting 'build variants' on the left edge). Then when actually pressing the debug button up top for my Android Application configuration (selected via drop down menu to the left of the Run/Debug icons), it would properly deploy the build variant mode I was in. (Would be nice if I could set up different Android App configurations to deploy different build types from the drop down menu instead of having to switch variants more manually, but I don't see how right now.)
Also in your buildTypes section in your build.gradle file, you probably want debuggable true
, else your process won't show up in the dialog if you try to manually attach the debugger.
I ran into the same behavior, the above solutions didn't work for me, but I have a bit of a corner case: my app extends android.app.Application. What I found works for me is to edit the run/debug configuration ("Edit Configurations..."), and select "Do not launch Activity" instead of "Launch default Activity".
I run into this problem just now, simple solution: if you have multiple instances running, make sure your run config specifiy different JMX port. refer to Image
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With