title: Android local unit test issue[JUnit 4.12]
body: <p>I am writing very simple local unit test to get app context and read string using that. Our intent is to unit test the API client and interface we have written to make a API call using retrofit 2x. </p>
  
  <p>Have added below dependencies in build.gradle file</p>
  
  <p><strong>Build.gradle :</strong> </p>
  
  <pre><code>defaultConfig {
          applicationId "x"
          minSdkVersion 23
          targetSdkVersion 28
          versionCode 89
          versionName "1.0"
          testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  }
  
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'androidx.test:runner:1.2.0'
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
  androidTestImplementation 'androidx.test:rules:1.3.0-alpha02'
  androidTestImplementation 'androidx.test.ext:junit:1.1.1'
  androidTestImplementation 'androidx.annotation:annotation:1.1.0'
  testImplementation 'com.squareup.okhttp3:mockwebserver:3.2.0'
  testImplementation 'androidx.test:core:1.2.0'
  </code></pre>
  
  <p><strong>Local Unit Test class :</strong></p>
  
  <pre><code>import android.content.Context
  import androidx.test.core.app.ApplicationProvider
  import org.junit.Test
  
  class ExampleAPITest {
      @Test
      fun useAppContext() {
      //  val context: Context = InstrumentationRegistry.getInstrumentation().targetContext
          val context: Context = ApplicationProvider.getApplicationContext&lt;Context&gt;()
          val appName = context.getString(R.string.app_name)
          println(appName)
      }
  }
  </code></pre>
  
  <p>We are using Espresso for test automation. So we have both dependencies added in the gradle file. 
  We are getting below exceptions while running local unit test ExampleUnitTest class, </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)
      at com.trimble.cec.appname.ExampleAPITest.loginApiTest(ExampleAPITest.kt:19)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
  </code></pre>
  
  <p>I know that we can use mockito or Robolectric to mock/access the android framework, We need only context to call the api service. Anyway we will be automating API call as part of Android Test. We need to build local test to test API calls locally. </p>
  
  <p>We have written our android test using Java and local unit test using Kotlin. </p>
  
  <p>Browsed for the above exception and tried different dependency versions, But nothing helps. Looks it is an android support test core library issue. Can someone help me to get rid of this issue. Thanks!</p>