Android Studio无法解决自定义项目布局中的androidTestImplementation依赖项

问题描述 投票:4回答:1

我有一个使用非标准源文件夹布局的项目,如下所示:

sourceSets {
    androidTest {
        manifest.srcFile "/myproject/androidTest/AndroidManifest.xml"

        java {
            srcDirs = [
                "/myproject/androidTest/java"
            ]
        }
    }
}

Android Studio很好地显示了上述源文件夹,并在树中将其标记为“ androidTest”。现在的问题开始于像espresso之类的依赖项在任何测试中都没有解决(在AS中找不到类)-尽管已经像这样正确声明了它们:

 androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

如果我将'androidTestImplementation'更改为'implementation',则Android Studio可以恢复并能够解决依赖关系(但我不想在我的实现范围中添加测试依赖项!]

这仅仅是Android Studio 3.2.1中的错误,还是我的设置中存在错误?

android android-studio gradle ide dependencies
1个回答
0
投票

有同样的问题。并意外找到解决方案...

只需使用括号...所以您的情况是:

androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2')
© www.soinside.com 2019 - 2024. All rights reserved.