如何安装/导入 AndroidJunitRunner

Chr*_*ine 6 junit android android-gradle-plugin

按照https://code.google.com/p/android-test-kit/wiki/EspressoSetupInstructions 上的说明,我添加了这些行

androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
androidTestCompile 'com.android.support.test:runner:0.3'
Run Code Online (Sandbox Code Playgroud)

到我的 gradle 构建文件,以及

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Run Code Online (Sandbox Code Playgroud)

aar 文件位于

/{sdk_home}/extras/android/m2repository
Run Code Online (Sandbox Code Playgroud)

显然,这并不意味着 gradle 现在可以找到它们。如何告诉 gradle 在那里查找文件,或者如何创建依赖项?将 aar 文件放在我的 libs 目录中并从那里导入它们不起作用。一般不适用于 aar 文件。

这是我的 gradle 构建文件:

repositories {
mavenCentral() // this or jcenter() required for testing-support-lib dependencies
mavenLocal()
}

    apply plugin: 'com.android.application'
apply plugin: 'findbugs'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.loqli.android"
    minSdkVersion 18
    targetSdkVersion 22
    multiDexEnabled = true

    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/DEPENDENCIES'
}

   sourceSets {
        main {
            java.srcDirs = ['src/main/java']
            resources.srcDirs = ['src/main/res']
        }
        androidTest {
            java.srcDirs = ['src/test/java']
            resources.srcDirs = ['src/test/res']
        }
    }

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}

dexOptions {
    incremental true
    javaMaxHeapSize "4096M"
}

}

dependencies {

wearApp project(':wear')

compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services-wearable:+'

compile 'com.android.support:support-annotations:22.2.0'

compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs/roboguice', include: ['*.jar'])

//androidTestCompile 'junit:junit:4.12'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'

androidTestCompile 'com.android.support.test:runner:0.3'
}
Run Code Online (Sandbox Code Playgroud)

编辑:更新的 gradle 构建文件