Why can't I import AndroidJUnit4 and ActivityTestRule into my unit test class?
<p>I'm having trouble importing some of the Android UI testing framework classes - I just can't figure out what is going wrong!</p>

<p>This is my class:</p>

<pre><code>@RunWith(AndroidJUnit4.class)
@LargeTest
public class ExampleUnitTest {

@Rule
public ActivityTestRule&lt;MainActivity&gt; mActivityRule = new ActivityTestRule(MainActivity.class);

@Test
public void listGoesOverTheFold() {
    onView(withText("Hello world!")).check(matches(isDisplayed()));
  }
}
</code></pre>

<p>But for some reason I get the errors 'cannot find symbol ActivityTestRule' and 'cannot find symbol AndroidJUnit4'. I've tried to import them but they cannot be found.</p>

<p>The dependencies in build.gradle are set to:</p>

<pre><code>compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
androidTestCompile 'com.android.support:support-annotations:23.4.0'

androidTestCompile 'com.android.support.test:runner:0.4'
androidTestCompile 'com.android.support.test:rules:0.4'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
</code></pre>

<p>So I think I have all the dependencies setup - I've been trying many things but with no luck.</p>

<p>Anyone have any ideas?</p>