title: java.lang.RuntimeException: Delegate runner 'androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner' for AndroidJUnit4 could not be loaded
body: <p>I'm using <code>androidx.test.runner.AndroidJUnitRunner</code> as my <code>testInstrumentationRunner</code> from <code>androidTestImplementation 'androidx.test:runner:1.2.0'</code>.  Also, I annotated my test with <code>androidx.test.ext.junit.runners.AndroidJUnit4</code> using the syntax <code>@RunWith(AndroidJUnit4.class)</code></p>
  
  <p>Suddenly I started getting the following error when I try to run <code>./gradlew connectedAndroidTest</code> across all device types and emulators that I could try.</p>
  
  <pre><code>java.lang.RuntimeException: Delegate runner 'androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner' for AndroidJUnit4 could not be loaded.
  at androidx.test.ext.junit.runners.AndroidJUnit4.throwInitializationError(AndroidJUnit4.java:92)
  at androidx.test.ext.junit.runners.AndroidJUnit4.loadRunner(AndroidJUnit4.java:82)
  at androidx.test.ext.junit.runners.AndroidJUnit4.loadRunner(AndroidJUnit4.java:51)
  at androidx.test.ext.junit.runners.AndroidJUnit4.&lt;init&gt;(AndroidJUnit4.java:46)
  at java.lang.reflect.Constructor.newInstance0(Native Method)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
  at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
  at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
  at androidx.test.internal.runner.junit4.AndroidAnnotatedBuilder.runnerForClass(AndroidAnnotatedBuilder.java:63)
  at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
  at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
  at androidx.test.internal.runner.AndroidRunnerBuilder.runnerForClass(AndroidRunnerBuilder.java:153)
  at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
  at androidx.test.internal.runner.TestLoader.doCreateRunner(TestLoader.java:73)
  at androidx.test.internal.runner.TestLoader.getRunnersFor(TestLoader.java:104)
  at androidx.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:793)
  at androidx.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:547)
  at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:390)
  at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2074)
  Caused by: java.lang.reflect.InvocationTargetException
  at java.lang.reflect.Constructor.newInstance0(Native Method)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
  at androidx.test.ext.junit.runners.AndroidJUnit4.loadRunner(AndroidJUnit4.java:72)
  ... 17 more
  Caused by: org.junit.runners.model.InitializationError
  at org.junit.runners.ParentRunner.validate(ParentRunner.java:418)
  at org.junit.runners.ParentRunner.&lt;init&gt;(ParentRunner.java:84)
  at org.junit.runners.BlockJUnit4ClassRunner.&lt;init&gt;(BlockJUnit4ClassRunner.java:65)
  at androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner.&lt;init&gt;(AndroidJUnit4ClassRunner.java:43)
  at androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner.&lt;init&gt;(AndroidJUnit4ClassRunner.java:48)
  ... 20 more
  </code></pre>
  
  <p>A similar stack trace is in <a href="https://stackoverflow.com/questions/55496047/delegate-runner-androidx-test-internal-runner-junit4-androidjunit4classrunner">Delegate runner &#39;androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner&#39; for AndroidJUnit4 could not be loaded</a> but the author seems to be asking about converting Java to Kotlin, which is not relevant to my question.</p>