According to the documentation for AndroidJUnit4,
- The gradle file should contain the following line:
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
- Change test class to
AndroidJUnit4ClassRunner
fromAndroidJUnit4
If it still doesn’t work, make sure that you clean and/or rebuild your project. Also you can check the current version directly in Google’s maven repository