Obviously I need the correct import statment to solve this problem. According to the docs for AndroidJUnit4, this should be
import android.support.test.runn
The same error occurred to me when I follow Google IOSched app and set up my project with three build types [debug,release,staging] where debug and release share the same source directory
sourceSets {
debug.java.srcDir 'src/debugRelease/java'
release.java.srcDir 'src/debugRelease/java'
}
In this case, specify the testBuildType in your module-level build.gradle file and the project should now be able to resolve symbol 'AndroidJUnit4'.
...
sourceSets {
debug.java.srcDir 'src/debugRelease/java'
release.java.srcDir 'src/debugRelease/java'
}
testBuildType "staging"
...
Reference: https://github.com/google/iosched/blob/master/mobile/build.gradle