I am adding Espresso to my project in Android Studio. I have installed the Support Repository and in fact have already been using pieces of it. Then I added these dependencies to app/build.gradle
per the install instructions:
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
in writing my test, auto complete recognizes the existence of the artifacts. But when I run I get this error:
error: package android.support.test does not exist
error: package org.junit does not exist
and a number of other subpackages to these two.
So I removed the two above lines from build.gradle and attempted to add then in the GUI project structure/modules/dependencies
neither 'com.android.support.test.espresso:espresso-core:2.0' nor 'com.android.support.test:testing-support-lib:0.1' appear as options to choose from. However, in my file system there is <sdk>\extras\android\m2repository\com\android\support\test\espresso\espresso-core\2.0\
with the full complement of files including espresso-core-2.0.aar
which I am able to open and navigate within it via winzip. In the file system it looks no different than the other libraries installed via SDK Manager with Support Repository.
Why doesn't android studio recognize this library?
Your help is greatly appreciated, no one else that I can find seems to have run into this problem. This is the closest I could find: Why do packages from library module does not exist upon compilation, even when Android Studio shows no errors in code?
I have tried reinstalling Support Repository twice.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With