Eugene
Eugene

Reputation: 60224

How to debug when running Robolectric tests in Android Studio?

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?

Upvotes: 40

Views: 11144

Answers (2)

Rogelio Triviño
Rogelio Triviño

Reputation: 6539

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.

Upvotes: 2

Eugene
Eugene

Reputation: 60224

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

Upvotes: 70

Related Questions