40

I need to run debug while my tests execution in Android Studio + Robolectric. Each time I try to run them by selecting debug for the test task from Gradle tasks I get the error message:

Error running package_name:app_name [test]: Unable to open debugger port : java.net.SocketException "Socket closed"

Any ideas?

0

2 Answers 2

70

I found the reason of the error. To make it run you need to uncheck the "Use in-process build" option in Compiler -> Gradle settings of Android Studio.

enter image description here

7
  • 1
    @HeathBorders can you please post detail how to make this work on Intellij Sep 2, 2014 at 20:42
  • 1
    I don't remember now. I hope past me would have added more notes or a different answer if there were more steps. Sep 3, 2014 at 19:14
  • This slows down the build, so I hope Google comes around to fix this in Android Studio. @HeathBorders: IntelliJ IDEA does not have this issue, as it doesn't support In-process build in the first place.
    – Nilzor
    Nov 19, 2014 at 10:54
  • 3
    This does not help me. Running Android Studio 1.1.0
    – parvus
    Apr 2, 2015 at 12:30
  • Where can I find this setting? Sorry I'm very new to Android Studio, and I don't like Android in general :P Jun 3, 2015 at 10:51
2

I was getting this error on linux, and the problem was that the another previous process has 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.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.