title: AndroidX : No instrumentation registered! Must run under a registering instrumentation
body: <p>I'm trying to run a local unit test that depends on the context, and was following this guide: <a href="https://developer.android.com/training/testing/unit-testing/local-unit-tests#kotlin" rel="noreferrer">https://developer.android.com/training/testing/unit-testing/local-unit-tests#kotlin</a>  and I set up my project like this (following this link : <a href="https://developer.android.com/training/testing/set-up-project" rel="noreferrer">https://developer.android.com/training/testing/set-up-project</a> ):</p>
  
  <p><strong>build.gradle(app)</strong></p>
  
  <pre><code>android {
  compileSdkVersion 28
  buildToolsVersion '27.0.3'
  defaultConfig {
      minSdkVersion 21
      targetSdkVersion 27
      versionCode 76
      versionName "2.6.0"
      testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
      multiDexEnabled true
  
  useLibrary 'android.test.runner'
      useLibrary 'android.test.base'
      useLibrary 'android.test.mock'
  
  }
  testOptions {
      unitTests.returnDefaultValues = true
      unitTests.all {
          // All the usual Gradle options.
          testLogging {
              events "passed", "skipped", "failed", "standardOut", "standardError"
              outputs.upToDateWhen { false }
              showStandardStreams = true
          }
      }
      unitTests.includeAndroidResources = true
  
  }
  dependencies {
  implementation fileTree(include: ['*.jar'], dir: 'libs')
  
  androidTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion", {
      exclude group: 'com.android.support', module: 'support-annotations'
  })
  // Espresso UI Testing dependencies
  implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
  androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
  androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
  
  testImplementation 'androidx.test:core:1.0.0'
  
  // AndroidJUnitRunner and JUnit Rules
  androidTestImplementation 'androidx.test:runner:1.1.0'
  androidTestImplementation 'androidx.test:rules:1.1.0'
  // Espresso Assertions
  androidTestImplementation 'androidx.test.ext:junit:1.0.0'
  androidTestImplementation 'androidx.test.ext:truth:1.0.0'
  androidTestImplementation 'com.google.truth:truth:0.42'
      implementation 'androidx.multidex:multidex:2.0.0'
  }
  </code></pre>
  
  <p>My espresso_version is <strong>espressoVersion = '3.1.0'</strong></p>
  
  <p>My test that is located in <strong><em>module-name/src/test/java/</em></strong> looks like this:</p>
  
  <pre><code>    import android.content.Context
  import androidx.test.core.app.ApplicationProvider
  import com.instacart.library.truetime.TrueTime
  import edu.mira.aula.shared.extensions.android.trueDateNow
  import edu.mira.aula.shared.network.ConnectivityHelper
  import kotlinx.coroutines.experimental.runBlocking
  import org.junit.Assert
  import org.junit.Before
  import org.junit.Test
  import java.util.*
  import java.util.concurrent.CountDownLatch
  
  class TimeExtensionsUnitTest {
  private lateinit var instrumentationCtx: Context
  
  @Before
  fun setup() {
      instrumentationCtx = ApplicationProvider.getApplicationContext&lt;Context&gt;()
  }
   @Test
  fun testTrueTimeValueReturnsIfInitialized() {
      if (ConnectivityHelper.isOnline(instrumentationCtx)) {
          runBlocking {
              val countDownLatch = CountDownLatch(1)
              TrueTime.build()
                      .withSharedPreferencesCache(instrumentationCtx)
                      .withConnectionTimeout(10000)
                      .initialize()
              countDownLatch.countDown()
  
              try {
                  countDownLatch.await()
                  val dateFromTrueTime = trueDateNow()
                  val normalDate = Date()
                  Assert.assertNotEquals(dateFromTrueTime, normalDate)
              } catch (e: InterruptedException) {
              }
          }
      }
  }
  </code></pre>
  
  <p>Everytime I run it, it gives me: </p>
  
  <pre><code>java.lang.IllegalStateException: No instrumentation registered! Must run under a registering instrumentation.
   at androidx.test.platform.app.InstrumentationRegistry.getInstrumentation(InstrumentationRegistry.java:45)
    at androidx.test.core.app.ApplicationProvider.getApplicationContext(ApplicationProvider.java:41)
  </code></pre>
  
  <p>If I run it as a Instrumental Test(changing the package) it runs without errors.
  But I thought that this guide was exactly to be able to run unit test using Android Framework classes such as Context.
  I even tried run that <code>class UnitTestSample</code> but the same error occurs.</p>
  
  <p>I also removed all android.support dependencies from my project</p>
  
  <p>Any ideas on how to solve it?</p>