I have a project which uses a non-standard source folder layout like this:
sourceSets {
androidTest {
manifest.srcFile "/myproject/androidTest/AndroidManifest.xml"
java {
srcDirs = [
"/myproject/androidTest/java"
]
}
}
}
Android studio shows the above source folder just fine and also tags it as "androidTest" in the tree. The problem now starts with dependencies like espresso not resolving in any of the tests (class not found in AS) - although they have been properly declared like this:
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
If I change 'androidTestImplementation' to just 'implementation' Android Studio recovers and is able to resolve the dependencies (but I do not want to add test dependencies to my implementation scope!)
Is this just a bug in Android Studio 3.2.1 or is there a bug in my setup?
androidTestImplementation—The dependency is only available in the androidTest source set. Android source sets are : main: Contains your app code. This code is shared amongst all different versions of the app you can build (known as build variants) androidTest: Contains tests known as instrumented tests.
Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.
Had the same problem. And accidentally found solution...
Just use brackets... so in your case it is:
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2')
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