I'm having a bit of a problem with the combination of the three components mentioned above.
I have a simple app and would like to test it, so I added a MainActivityTest class to src/instrumentTest/java/<package-name>.test. That works pretty well and I've used the Robotium library to make testing a bit easier here. I've added the dependency on Robotium to the build.gradle file with an instrumentTestCompile directive in the dependencies block.
Due to various reasons I would want to use the testBuildType option. I've created a new buildType called "testWrapper" by using "testWrapper.initWith(buildTypes.debug)" and set the packageNameSuffix to ".test" so that I can install the app for testing separately on the device. After that I've set the testBuildType to "testWrapper".
At that point Android Studio suddenly fails to import the Robotium library. When I run the connectedInstrumentTest task it works without problem, but Android Studio apparently fails to understand the dependency logic.
This looks like a bug in Android Studio to me, but maybe I'm doing something wrong. If anyone has an idea, I'd love to hear it!
In the meantime I've discovered how to make Android Studio find the imports again: Go to File -> Project Structure and if you see any unused dependency errors there, fix them by adding the dependencies to the project manually.
Even though the above solutions kinda works, I don't think this is the desired behavior and I hope it will get fixed soon.