Didn't find class "android.support.test.runner.AndroidJUnitRunner"

Inside the build.gradle file there you find the defaultConfig section. With the testInstrumentationRunner attribute the respective test runner can be specified. There the test runner from the android.support package might be specified:

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

this has to be change to the test runner from the androidx package:

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Didn't find class "android.support.test.runner.AndroidJUnitRunner"

You migrated to AndroidX but as you can see, there is-are still usages of android.support test libraries in your project.

To solve this, you should search for anything in anywhere in your project which starts by android.support and replace it or removing it to use AndroidX libraries.


I had the same issue when i forgot to add a dependency to the android test runner.
So adding this helped:

androidTestImplementation("androidx.test:runner:1.2.0")

Tags:

Android