"RobolectricTestRunner.class" not recognized in Android Studio

I solved the issue just by putting the test class inside the src \ test folder instead of putting it in thesrc \ androidTest folder


Usually there will be 2 kinds of tests 'androidTest' and 'test'.

If you add dependency like androidTestImplementation 'org.robolectric:robolectric:4.3.1', Robolectric package will only be imported in 'androidTest' classes.

If you add dependency like testImplementation 'org.robolectric:robolectric:4.3.1', they can only be imported in 'test' classes.