Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio does not resolve androidTestImplementation dependencies in custom project layout

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?

like image 790
light_303 Avatar asked Nov 27 '18 14:11

light_303


People also ask

What is androidTestImplementation?

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.

Does Android Studio include Gradle?

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.


1 Answers

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')
like image 176
Brontes Avatar answered Oct 13 '22 05:10

Brontes