Obviously, to solve this problem I need the right import. According to docs for AndroidJUnit4 , this should be
import android.support.test.runner.AndroidJUnit4;
When I do this, Android Studio highlights the runner red and complains of "Cannot resolve the runner symbol."
Background
I got to this by following the instructions on the Android developer site to configure tests using the UI Automator . The first problem I ran into was that com.android.support:support-v4:22.2.0 and com.android.support.test:runner:0.2 depend on different versions of com.android.support:support-annotations . I followed the suggestions of this Android error report and added the following to allprojects :
configurations.all { resolutionStrategy.force 'com.android.support:support-annotations:22.1.0' }
This resolved the immediate mistake, but I suspect that it led to my current problems. Anyone have suggestions for fixing this?
Relevant sections from .. / gradlew: app: dependencies
androidTestCompile - Classpath for compiling the androidTest sources. +--- com.jayway.android.robotium:robotium-solo:5.2.1 +--- com.squareup:fest-android:1.0.8 | \--- org.easytesting:fest-assert-core:2.0M10 | \--- org.easytesting:fest-util:1.2.5 +--- com.android.support.test:runner:0.2 | +--- junit:junit-dep:4.10 | | \--- org.hamcrest:hamcrest-core:1.1 | +--- com.android.support.test:exposed-instrumentation-api-publish:0.2 | \--- com.android.support:support-annotations:22.0.0 -> 22.2.0 +--- com.android.support.test:rules:0.2 | \--- com.android.support.test:runner:0.2 (*) \--- com.android.support.test.uiautomator:uiautomator-v18:2.1.0 compile - Classpath for compiling the main sources. +--- com.android.support:appcompat-v7:22.2.0 | \--- com.android.support:support-v4:22.2.0 | \--- com.android.support:support-annotations:22.2.0 +--- com.android.support:support-v4:22.2.0 (*) +--- com.google.android.gms:play-services:6.1.71 | \--- com.android.support:support-v4:20.0.0 -> 22.2.0 (*) +--- com.crashlytics.android:crashlytics:1.+ -> 1.1.13 \--- com.jakewharton:butterknife:5.1.2
android build.gradle gradle android-uiautomator testing-support-library
Code-Apprentice Jun 02 '15 at 18:10 2015-06-02 18:10
source share