title: Android Unit Testing dependencies not found
body: <p>I am trying to write the following unit test for a function in my project</p>
  <pre><code>import android.content.Context
  import org.junit.Test
  import androidx.test.core.app.ApplicationProvider
  import com.adi_random.tracky.api.searchBook
  import com.adi_random.tracky.models.GoodreadsBook
  import com.google.gson.Gson
  import okhttp3.Call
  import okhttp3.Callback
  import okhttp3.Response
  import java.io.IOException
  import com.google.common.truth.Truth.assertThat
  
  /**
   * Created by meadi on 6/27/2020.
   */
  class BookFetchTest {
      /**
       * Test if the Tracy API searchBook endpoint returns the expected result and gets parsed correctly
       */
      val context = ApplicationProvider.getApplicationContext&lt;Context&gt;()
  
      @Test
      fun bookFetchResultValidation() {
          val query = &quot;Dune&quot;;
          searchBook(query, context, object : Callback {
              override fun onFailure(call: Call, e: IOException) {
                  TODO(&quot;Not yet implemented&quot;)
              }
  
              override fun onResponse(call: Call, response: Response) {
                  val gson = Gson();
                  val res = gson.fromJson&lt;Array&lt;GoodreadsBook&gt;&gt;(
                      response.body?.charStream(),
                      Array&lt;GoodreadsBook&gt;
                      ::class.java
                  )
                  assertThat(res).hasLength(20);
              }
  
          })
      }
  }
  </code></pre>
  <p>When hitting run, I am getting <code>Unresolved reference</code> in <code>:app:compileDebugUnitTestKotlin</code> gradle task for the following dependencies: test (double clicking the error highlights <code>androidx.test.core.app.ApplicationProvider</code>), common ( in <code>com.google.common.truth.Truth.assertThat</code>), ApplicationProvider ( in <code>ApplicationProvider.getApplicationContext()</code>) and assertThat (in the <code>assertThat</code> call at the end of the test).</p>
  <p>Here is my module <code>build.gradle</code> file:</p>
  <pre><code>apply plugin: 'com.android.application'
  apply plugin: 'kotlin-android'
  apply plugin: 'kotlin-android-extensions'
  
  android {
      compileSdkVersion 29
      buildToolsVersion &quot;29.0.3&quot;
      buildFeatures {
          viewBinding true
      }
      testOptions {
          unitTests.includeAndroidResources = true
      }
      defaultConfig {
          applicationId &quot;com.adi_random.tracky&quot;
          minSdkVersion 23
          targetSdkVersion 29
          versionCode 1
          versionName &quot;1.0&quot;
  
          testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
          }
      }
      compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
      }
      kotlinOptions {
          jvmTarget = '1.8'
      }
      useLibrary 'android.test.runner'
      useLibrary 'android.test.base'
      useLibrary 'android.test.mock'
  }
  
  dependencies {
      implementation fileTree(dir: &quot;libs&quot;, include: [&quot;*.jar&quot;])
      implementation &quot;org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version&quot;
      implementation 'androidx.core:core-ktx:1.3.0'
      implementation 'androidx.appcompat:appcompat:1.1.0'
      implementation 'com.squareup.okhttp3:okhttp:4.1.0'
      implementation 'com.google.code.gson:gson:2.8.6'
      implementation 'com.google.android.material:material:1.0.0'
      implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
      implementation 'androidx.navigation:navigation-fragment-ktx:2.1.0'
      implementation 'androidx.navigation:navigation-ui-ktx:2.1.0'
      implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
      implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'androidx.test.ext:junit:1.1.1'
      androidTestImplementation 'androidx.test.ext:truth:1.2.0'
      androidTestImplementation 'com.google.truth:truth:0.42'
      androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
      androidTestImplementation 'androidx.test:core:1.2.0'
  
      // AndroidJUnitRunner and JUnit Rules
      androidTestImplementation 'androidx.test:runner:1.2.0'
      androidTestImplementation 'androidx.test:rules:1.2.0'
  
  }
  </code></pre>
  <p>As you can see I have those dependencies added to my gradle build file with the <code>androidTestImplementation</code> directive, so I don't understand why those errors get thrown. Does anyone have any idea? Thanks in advance!</p>
  <p>Edit:Here is a screenshot of the problem:
  <a href="https://i.stack.imgur.com/OQ5vD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OQ5vD.png" alt="enter image description here" /></a></p>