title: java.lang.RuntimeException: Delegate runner androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner for AndroidJUnit4 could not be found
body: <p>I am new to android testing and I don´t know how to solve this problem.
  Trying to run the following test file from my project:</p>
  <pre class="lang-kotlin prettyprint-override"><code>@RunWith(AndroidJUnit4::class)
  class AppDatabaseTest {
    private lateinit var userDAO: UserDAO // custom DAO interface
    private lateinit var db: AppDatabase
  
    @Before
    fun createDb() {
      db = Room.inMemoryDatabaseBuilder(
        ApplicationProvider.getApplicationContext(),
        AppDatabase::class.java
      ).allowMainThreadQueries().build()
  
      userDAO = db.userDAO()
    }
  
    @After
    @Throws(IOException::class)
    fun closeDb() {
      db.close()
    }
  
    @Test
    @Throws(Exception::class)
    fun insertAndReadUser() {
      val user = User(
        1,
        &quot;123&quot;,
        &quot;Test Name&quot;,
        &quot;link.to/name/image#from_the.web&quot;
      )
      userDAO.insert(user)
  
      val inserted = userDAO.getByUID(1)
      assertThat(inserted).isNotNull()
    }
  }
  </code></pre>
  <p>Throws the following error on the run log:</p>
  <blockquote>
  <p>java.lang.RuntimeException: Delegate runner androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner for AndroidJUnit4 could not be found.</p>
  </blockquote>
  <blockquote>
  <p>Caused by: java.lang.ClassNotFoundException: androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner</p>
  </blockquote>
  <p>Here are the project dependencies:</p>
  <pre class="lang-kotlin prettyprint-override"><code>dependencies {
      def room_version = &quot;2.2.6&quot;
  
      implementation &quot;androidx.room:room-runtime:$room_version&quot;
      kapt &quot;androidx.room:room-compiler:$room_version&quot;
      implementation &quot;androidx.room:room-ktx:$room_version&quot;
  
      implementation &quot;org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version&quot;
      implementation 'androidx.core:core-ktx:1.3.2'
      implementation 'androidx.appcompat:appcompat:1.2.0'
      implementation 'com.google.android.material:material:1.2.1'
      implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
      implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2'
      implementation 'androidx.navigation:navigation-ui-ktx:2.3.2'
      implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
      implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
      implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2'
      implementation 'androidx.navigation:navigation-ui-ktx:2.3.2'
  
      testImplementation 'com.google.truth:truth:1.1'
      testImplementation 'junit:junit:4.13.1'
      testImplementation 'androidx.test.ext:junit:1.1.2'
  
      androidTestImplementation 'androidx.test.ext:junit:1.1.2'
      androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
  }
  </code></pre>
  <p>What could be causing this error and how to fix it?</p>
  <p>Android Studio 4.1.1</p>