Cannot resolve symbol 'AndroidJUnit4'
Make sure your app in debug build variant. Go to Build > Select Build Variant... and the following should show up:
I made the mistake to put the test classes at src/test. After moving them to src/androidTest/java/ the dependency was resolved.
Ok so here is your mistake and mine!
If we are going to write a pice of code for Local Unit Testing we shouldn't use @RunWith(AndroidJUnit4.class)
cause we do not use AndroidJUnit4 but we need Junit4. so we should write @RunWith(JUnit4.class)
. And of course your java test file is under app/src/test/java/your.package.name
directory.
Else if (!!) we want to write some Android Instrumented Unit Test we should put our test java files in app/src/androidTest/java/your.package.name
directory and use annotation like @RunWith(AndroidJUnit4.class)