简体   繁体   English

testCompile导致Android studio无法解析依赖关系

[英]testCompile results in Android studio not resolving dependencies

I have my tests in MainProject/Project/src/test. 我在MainProject / Project / src / test中进行了测试。 I am using Jake Wharton's gradle-android-test-plugin. 我正在使用Jake Wharton的gradle-android-test-plugin。 Whenever I specify a dependency with testCompile, it doesn't auto-complete in the IDE. 每当我使用testCompile指定依赖项时,它都不会在IDE中自动完成。 But it does compile. 但它确实编译。

my build.gradle looks like this: 我的build.gradle看起来像这样:

buildscript {
    repositories {
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
        classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.1-SNAPSHOT'

    }
}
apply plugin: 'android'
apply plugin: 'android-test'


repositories {
    mavenCentral()
}

dependencies {

    testCompile 'junit:junit:4.11'

}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"
}

but whenever I try to code it does this: 但每当我尝试编码时,它会这样做:

在此输入图像描述

It is annoying and descreases my productivity. 这很烦人,降低了我的工作效率。 Any suggestions on how to resolve this? 有关如何解决此问题的任何建议? Thanks. 谢谢。

I've had the same problem. 我遇到了同样的问题。 My temporary solution is to repeat the testCompile dependencies in instrumentTestCompile. 我的临时解决方案是在instrumentTestCompile中重复testCompile依赖项。

This way, the Android Studio recognises the instrumentTestCompile dependencies and starts auto-completing. 这样,Android Studio识别instrumentTestCompile依赖项并开始自动完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM