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

Joh*_*y Z 4 android android-studio android-gradle-plugin

我在MainProject/Project/src/test中进行了测试.我正在使用Jake Wharton的gradle-android-test-plugin.每当我使用testCompile指定依赖项时,它都不会在IDE中自动完成.但它确实编译.

我的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"
}
Run Code Online (Sandbox Code Playgroud)

但每当我尝试编码时,它会这样做:

在此输入图像描述

这很烦人,降低了我的工作效率.有关如何解决此问题的任何建议?谢谢.

Fer*_*rgo 7

我遇到了同样的问题.我的临时解决方案是在instrumentTestCompile中重复testCompile依赖项.

这样,Android Studio识别instrumentTestCompile依赖项并开始自动完成.

  • 现在使用`androidTestCompile`而不是`instrumentTestCompile`(很可能是Android Gradle插件版本0.9.0) (11认同)