How to debug when running Robolectric tests in Android Studio?

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

Error starting package_name: app_name [test]: cannot open the debugger port: java.net.SocketException "Socket closed"

Any ideas?

+40
android debugging android-studio gradle robolectric
Jan 17 '14 at 11:10
source share
2 answers

I found the cause of the error. To run it, you need to uncheck the "Use built-in assembly" in the settings of the Compiler → Gradle in Android Studio.

enter image description here

+70
Jan 17 '14 at 14:27
source share

I was getting this error on Linux, and the problem was that another previous process took the port and hung it. Thus, the solution is netstat to find a process blocking a port, then kill that process or restart the computer.

+1
Nov 07 '16 at 10:39
source share



All Articles