Why Is Library Module Android.support.test Not Visible In Add Dependency
Solution 1:
I had the same issue and I found that the dependencies with the androidTestCompile are visible only by default in the debug build variant.
You can change the build variant to be tested by adding this to your build.gradle:
android {
...
testBuildType "staging"
}
where "staging" is just an example, you should replace it with one of your build variant.
Remember that only one variant is tested.
More information here https://code.google.com/p/android/issues/detail?id=98326
Solution 2:
There are 2 different test dependencies configurations:
testCompile
- used by unit test suite (located insrc/test
folder and invoked by./gradlew test
)androidTestCompile
- used by integration test suite (located atsrc/androidTest
folder and invoked by./gradlew connectedAndroidTest
).
My suspicion is that your test code is in the wrong test suite location
In your case your test code should go into src/androidTest
folder and test suite should be executed by running ./gradlew connectedAndroidTest
Solution 3:
I had this issue as well and I have my android test cases under src/androidTests as recommended by Google, but this caused problems with build.gradle:
sourceSets {
main {
java.srcDirs = ['src']
}
}
With the above it's trying to compile all my test cases within the normal debug compilation target, which does not include the espresso and other dependencies because they're listed under androidTestCompile.
In the end I fixed this by excluding the androidTest subdirectory from compilation and set the root of androidTest to the appropriate directory.
sourceSets {
main {
java.srcDirs = ['src']
java.excludes = ['androidTest/**']
}
androidTest.setRoot('src/androidTest')
}
Solution 4:
I've had the same problem and it was solved by hitting Clean Project from the Build tab in Android Studio.
After hitting Clean Project, watch the Gradle Console for potential errors and if it completes the cleaning successfully, simply go into any one of your test classes and type in "Espresso" and the smart code completion should offer suggestions. Everything should automatically import as you use Espresso after that.
Hope this helps!
Solution 5:
My solution was easier and simpler, I just went to Android Studio File>Invalidate Caches/Restart
and it worked properly, seems that android studio is keeping some cache that will not clean with Rebuild/Clean
.
Post a Comment for "Why Is Library Module Android.support.test Not Visible In Add Dependency"