Reputation: 3535
I have an issue in my instrumentation test (for which I use Robotium), so I decided to debug it. I usually run the test from command line with gradlew connectedAndroidTest
, but it runs as well from Android Studio (v0.8.14) by selecting the specific gradle task. However if I try to debug that gradle task, I get an error Unable to open debugger port : java.net.SocketException "socket closed"
and the test continues to run (without debugging). Is there another way to debug instrumentation test (with IDE) or I am missing something in my setup?
Update: However, it works on emulator!
Upvotes: 6
Views: 2454
Reputation: 11792
I had the same problem. You're just running the tests in the wrong way. Instead of clicking "debug" on the gradle task "connectedAndroidTest" go to "Edit run configurations" in Android Studio. Click the "plus" sign and add a new "Android Tests" configuration. Then - select the module your tests reside in (probably the main module of your app) and save the configuration. Click "debug" on the newly created config.
Upvotes: 7