How to install / import AndroidJunitRunner

Following the instructions at https://code.google.com/p/android-test-kit/wiki/EspressoSetupInstructions I added the lines

androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
androidTestCompile 'com.android.support.test:runner:0.3'

      

to your gradle build file and

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

      

Aar files are available at

/{sdk_home}/extras/android/m2repository

      

Apparently this does not mean that gradle can find them now. How do I tell gradle to look for files there, or how do I create a dependency? Putting aar files into my libs directory and importing them from them doesn't work. Doesn't work for aar files in general.

This is my gradle build file:

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'
}

      

edit: updated gradle build file

+3


source to share





All Articles